Planning
Plan-then-execute and dynamic replanning so agents tackle multi-step goals without thrashing.
In plain words
The AI first writes a to-do list for the task, works through it, and rewrites the list if something goes wrong.
Think of it like…
A project manager's checklist: before starting, list the steps, assign them, and update the list when something unexpected happens. Without a list, the team works hard but may forget half the steps or do some twice.
Where you’ve seen it
A data-analysis agent gets "Why did conversion drop in October?". The planner outputs six steps: check data freshness, compare conversion by channel, by device, by country, check release dates, and summarise. A cheaper executor model runs steps 2 to 4 in parallel. Step 2 reveals one paid channel changed on 12 October, so the planner replans: add "inspect the campaign change" and drop "compare by country". Fixed-plan runs miss the channel insight; step-only runs average 14 tool calls versus 9 with planning.
Words you’ll hear
- Plan-and-execute
- A planner writes the full plan first; an executor carries out steps.
- Replanning
- Updating the remaining plan after observations, failures or new information.
- Decomposition
- Splitting a goal into sub-goals that can be tackled independently.
- Plan verification
- Reviewing a plan (by a critic, rules or a human) before executing it.
Visual diagram
Theory & deep dive
Planning patterns
Plan-and-execute separates concerns: a capable model creates a structured plan (JSON list of steps with ids, descriptions, tools and dependencies), and a cheaper executor runs each step, often with a ReAct loop inside. Variants like ReWOO plan the whole tool-call graph upfront with placeholders for results, and LLMCompiler schedules independent calls in parallel, reducing latency and tokens versus step-by-step reasoning.
Dynamic planning keeps only a short horizon: decide the next few steps, observe, and plan again, which handles uncertainty better but can drift. A hybrid works well: a high-level plan with replanning triggers (a step fails, a result contradicts an assumption, a budget threshold passes). Represent plans as data, not prose, so you can track status (pending, running, done, failed), enforce dependencies and show progress.
[{"id": 1, "task": "Check data freshness", "tool": "query_sql", "depends_on": []}, {"id": 2, "task": "Conversion by channel", "tool": "query_sql", "depends_on": [1]}, {"id": 3, "task": "Conversion by device", "tool": "query_sql", "depends_on": [1]}] Steps 2 and 3 can run in parallel after step 1.
When planning helps, and its risks
Planning pays off for long, multi-part tasks with identifiable sub-goals (research, analysis, migrations), when parallelism is possible, when cost matters (a strong planner plus a cheap executor), and when humans must approve the approach. It's wasteful for short tasks (one or two tool calls), and brittle when the environment is unpredictable or the plan encodes wrong assumptions.
Risks and mitigations: plans can be wrong or too ambitious (ask for a verification pass or a human review of high-impact plans); executors may deviate (track step status and compare outputs to expected formats); replanning can oscillate (cap replans and keep completed work); and plans consume tokens (keep them concise). Evaluate on task success, steps, cost and latency against a no-plan baseline: planning should earn its overhead.
Replan when a step fails twice, when a result invalidates a stated assumption ("data is up to date" turns out false), or when 70% of the budget is used with under 50% of steps complete. Keep finished steps and rewrite only the remainder.
How it works, step by step
Step 1 of 41. Decide if planning is worth it
Use planning for long, multi-part, parallelisable or reviewable tasks; skip it for short ones.
- Baseline
- compare no-plan
When to use it & trade-offs
What it is
Planning gives an agent an explicit structure for multi-step goals. In plan-then-execute, a planner writes a step list ("1. fetch last quarter's sales; 2. fetch the forecast; 3. compare; 4. write a summary"), an executor works through it step by step, and the system replans when a step fails or reveals new information. Related patterns: decomposition (break a goal into sub-goals, possibly run in parallel), dynamic replanning (revise the plan as evidence arrives) and plan verification (check the plan before acting).
Why it matters: A step-by-step agent that decides only the next action can thrash: wander, repeat work, or lose track of the goal on long tasks. A plan keeps the goal in view, enables parallel execution and cheaper executors, and makes the work reviewable by a human before it runs. But rigid plans break when reality differs, and over-planning wastes tokens, so the skill is choosing how much to plan.
When to reach for it
- Research and analysis with several independent sub-questions
- Multi-system operations that need approval before running
- Cost control through strong planner plus cheap executor
When to avoid or be careful
- Planning for tasks needing one or two tool calls
- Following a plan after evidence contradicts it
- Unlimited replanning
Planning approaches
Strengths: Adapts immediately; simple.
Watch out: Can wander on long tasks; sequential.
Strengths: Parallelism; cheaper executors; reviewable.
Watch out: Plans can be wrong; needs replanning.
Strengths: Combines structure with adaptation.
Watch out: More model calls; risk of oscillation.
Interview signals & numbers to know
When this topic comes up
- “The agent forgets steps on long tasks”
- “Plan-and-execute vs ReAct”
- “Run independent steps in parallel”
- Replanning triggers
- Plan review before execution
Benchmarks & rules of thumb
- 14 → 9
- tool calls per run without vs with planning in the example
- 3
- a reasonable replan cap
- 70% / 50%
- budget vs progress replanning trigger in the example
Common mistakes & follow-ups
Common interview mistakes
- Asking for a 20-step plan for a task that needs two lookups.
- Executing the original plan after step 2 proved a key assumption false.
- Letting the planner and executor replan each other indefinitely.
Likely interviewer follow-ups
- When would you use plan-and-execute instead of ReAct?
- How do you decide when to replan?
- How would you let a human review a plan?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Planning with generative AI interview Q&A and hands-on practice.