Heat half the oil in a heavy-based saucepan. Add the onions, garlic and a pinch of sugar. Stir, cover and cook gently over a low heat for 30 minutes. Leave to cool.
Preheat the oven to 200°C. Mix the butter and remaining oil together. Brush half a sheet of filo with a little of the oil mixture, then lay three more pieces on top at angles to each other to form a star shape, oiling each sheet as you go.
Scatter a quarter of the onions in the centre of the pastry and sprinkle with a quarter of the walnuts. Place one round of goat's cheese on top. Scatter over ½ teaspoon of the thyme leaves and season with pepper. Gather up the edges of the pastry and pinch together to enclose the filling and make a purse shape. Repeat to make three more purses.
Put the purses on a non-stick baking tray. Brush lightly with the remaining oil mixture. Bake for 10–15 minutes until golden. If you like, tie each purse with a sprig of thyme.