Advanced11 min
Plan-and-Execute & Routing
Two patterns for complex agents: upfront planning that decomposes tasks into steps, and routing that dispatches to specialized sub-agents.
Quick Reference
- →Plan-and-Execute: a planner LLM creates a step-by-step plan, then an executor agent runs each step sequentially
- →Store the plan in graph state as a list of steps with status tracking (pending, running, done, failed)
- →Routing: a classifier node reads the input and routes to one of N specialized sub-graphs based on intent
- →Use structured output for the router (intent: enum, confidence: float) to make routing deterministic
- →Combine both patterns: route to the right domain, then plan-and-execute within that domain
Plan-and-Execute Pattern
When to use
Plan-and-Execute shines when the task has 4+ steps that depend on each other, and the agent needs to track progress across those steps. Examples: research reports, data analysis, multi-step API workflows.
Plan-and-execute: planner decomposes the task, executor runs steps, replanner adjusts until done
Plan-and-Execute agent with dynamic re-planning