7 Planning and reflection for complex tasks
This chapter covers
- The limitations of reactive agents on complex tasks
- Planning tools that decompose problems into task lists
- Reflection tools that enable progress checking and failure recovery
- The complementary cycle of planning and reflection
We’ve built an agent that observes the current situation, decides which tool to call, and repeats this cycle. This reactive approach works well for simple tasks but struggles with complex problems requiring multiple steps. The agent loses direction, forgets what it has done, or fails to recover from errors. Planning and reflection address these limitations by giving agents "time to think." Planning decomposes complex problems into manageable tasks before execution. Reflection pauses to check progress and adjust direction when things go wrong.
Figure 7.1 The roles of planning and reflection in AI agents.
We’ll examine why reactive agents fail and how human experts approach complex tasks differently. We’ll then implement a simple Planning tool that records task lists in the context, followed by a reflection tool that enables progress checking and failure recovery. Finally, we combine both strategies into a complementary cycle and see how they resolve the failure modes of reactive agents.