Heat olive oil in a deep saucepan. Add leek, sage and garlic and stir to coat in oil. Cook over a medium heat until the leek has softened and collapsed a bit.
Add pumpkin, lentils and stock. I add some pepper now too, but wait until later to taste and adjust salt seasoning.
Simmer for about half an hour, stirring occasionally, or until the pumpkin is soft. The lentils will more or less have disappeared by now.
Use a jug or stick blender to blend until smooth. Taste and adjust seasoning, and add a little more water if necessary to reach your desired consistency.
For the pesto:
Use a jug or stick blender, food processor or mortar and pestle to blend ingredients until fairly smooth. Taste and adjust seasoning. Add a little water to thin if it's too thick, or more lemon juice.