Chapter 8: Single-Agent Patterns
These patterns describe how an individual agent approaches tasks.
Pattern 1: ReAct (Reason + Act)
The foundational pattern for agentic behaviour. The agent explicitly reasons about what to do before taking action, then observes the result and reasons again.
- THINK → What do I need to do? What's my plan?
- ACT → Execute one step (call a tool, generate output)
- OBSERVE → What happened? Did it work?
- REPEAT → Continue until done or stuck
When to use: Most agentic tasks. This is your default pattern.
Pattern 2: Tool Use
The agent has access to external tools and decides when and how to use them. Tools extend the agent beyond text generation into real-world actions.
Key design considerations:
- Clear tool definitions: The agent needs to understand what each tool does
- Minimal, focused tools: Better to have specific tools than general-purpose ones
- Error handling: Tools fail, the agent needs to handle failures gracefully
When to use: Whenever the agent needs to retrieve information, take actions, or interact with external systems.
Pattern 3: Reflection
The agent reviews its own output before finalising, asking "Is this right? Is this complete? Could this be better?"
- GENERATE → Produce initial output
- CRITIQUE → Evaluate the output against criteria
- REFINE → Improve based on the critique
- REPEAT → Until quality threshold met
When to use: High-stakes outputs where quality matters more than speed.
Pattern 4: Planning
Before acting, the agent creates an explicit plan — breaking a complex goal into steps, identifying dependencies, and sequencing the work.
When to use: Complex, multi-step tasks where upfront planning reduces wasted effort.
Pattern 5: Fallback & Escalation
The agent recognises when it's stuck, uncertain, or out of scope — and responds appropriately rather than guessing or failing silently.
Fallback strategies:
- Try an alternative approach
- Ask clarifying questions
- Provide a partial answer with caveats
- Escalate to a human or another agent
When to use: Always. Every agent needs graceful failure handling.
