Melt the butter in a frying pan, add the onions, garlic, sage and salt and pepper and cook over a medium heat, stirring occasionally, for 20–25 minutes until soft and golden. Leave to cool.
Meanwhile, cut the pumpkin into 5 mm (¼ inch) thick slices and brush with the oil. Heat a ridged griddle pan until hot. Add the pumpkin, in batches, and cook for 2–3 minutes on each side until tender. Leave to cool.
Roll one pastry block out on a lightly floured work surface to form a rectangle a little smaller than a baking sheet. Lay on the sheet. Spread over half the onion mixture, leaving a 2.5 cm (1 inch) border. Top with half the pumpkin and half the cheese. Repeat these layers, seasoning with salt and pepper.
Roll out the remaining pastry a little larger than the first. Brush around the filling with beaten egg and top with the second piece of pastry. Press the edges together to seal, then decorate with the tines of a fork. Brush with beaten egg and score the surface with slashes.
Bake in a preheated oven, 220°C (425°F), Gas Mark 7, for 25–30 minutes until puffed and golden. Leave to cool slightly, then cut into slices and serve warm.