Chapter 6. Planning and Reflection
In Chapter 3, we covered reasoning LLMs and their capabilities to demonstrate complex chains of thought. Advanced reasoning enables behavior that is vital in agentic systems, namely the ability to plan actions and reflect on them.
Agents are multi-step entities and generally require planning the actions they will take to complete their goals. Imagine you ask an agent to create a specific feature for your codebase. To bring this to completion, typical steps the agent takes include:
-
Clarify requirements
-
Analyze the existing codebase
-
Design the feature
-
Implement the feature
-
Test the feature
-
Update documentation
To execute all these actions, the agent first needs to be aware of them and track the status of its current state. Planning is essential to solidify this behavior and to allow the agent to dynamically adjust the plan when necessary. After all, without a plan, how would it know what to do next?
This plan and the steps that it contains can often be taken multiple times, such as implementing and testing the feature whenever the agent encounters a bug. Iterative loops are similarly a fundamental component of what makes an agent. As such, the initial plans are made malleable and should be open to change when there is an issue with the plan or its execution. Reflection on what has been done and what could be improved is, therefore, vital for the autonomous nature of the agent. Planning and reflection go hand in hand, and by implementing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access