Planning and task decomposition
Long tasks go better when the agent breaks them into steps. Compare planning first with deciding step by step, and learn when to change the plan.
In 60 seconds
Planning and task decomposition
Long tasks go better when the agent breaks them into steps. Compare planning first with deciding step by step, and learn when to change the plan.
Two styles
- The model thinks, picks one action, sees the result, and decides the next step
- Adapts quickly to surprises
- Can wander, forget the goal, or loop on long tasks
- Good for short, uncertain tasks like debugging or search
- The model first writes a full list of steps, then carries them out
- Easy to show a person and to check progress
- The plan can be wrong if early results surprise you
- Good for longer tasks with a known shape, like reports
A plan as data, not just text
{
"goal": "Compare 3 prepaid mobile plans under Rs 300 for my parents",
"steps": [
{"id": 1, "task": "Find current plans from 3 operators", "status": "done"},
{"id": 2, "task": "Note price, validity, data per day, calls", "status": "in_progress"},
{"id": 3, "task": "Check which ones need a specific app to recharge", "status": "todo"},
{"id": 4, "task": "Write a short comparison in simple Hindi and English", "status": "todo"}
]
}Executing and replanning
- 1
Plan
One model call turns the goal into 3 to 7 concrete steps, each with a clear 'done' test. - 2
Execute a step
Run the normal agent loop for just this step, with the plan and progress in context. - 3
Update the checklist
Mark it done, or failed with a reason. Your code stores this, not only the model. - 4
Replan when needed
If a step fails or new facts appear, ask the model to revise the remaining steps. - 5
Finish
When all steps are done, check the result against the original goal before answering.
Tips that help in practice
- Ask for steps with a clear finish line: "list 3 plans with price" is better than "research plans".
- Limit the number of steps. A plan of 40 steps is usually a sign the task should be split or simplified.
- Put the goal and the checklist near the top of every step's context, so the model does not lose track.
- Allow a replan only a few times. An agent that replans forever is another kind of loop.
- For risky tasks, show the plan to a person before execution. Approving a plan is easier than approving 20 single actions.
Watch and read more
Lab
A plan-then-execute design for a real task, with done-tests, replan rules and an approval point.
The problem
Design, on paper or in a text file, an agent that helps a small shop owner in Jaipur "find three local suppliers of cotton bags and draft an enquiry message to each".
- Write the plan as JSON: a goal and 4 to 6 steps, each with a clear done-test.
- Mark which steps use read tools and which use write tools.
- Write two rules for when the agent must replan, and a maximum number of replans.
- Choose where a person must approve before the agent continues, and explain why there.
You are done when
Hard questions
Try to answer before you reveal. If you can answer these, you understood the lesson.
Q1Your agent plans 5 steps, but step 2 finds only one supplier, not three. Should it replan, continue, or stop? Explain.Reveal
It depends on the goal. Blindly continuing would draft messages to suppliers that do not exist. A good design replans: for example, widen the search area or search a different kind of source, within the replan limit. If it still cannot find three, it should stop and report honestly ("found one; here is why") instead of inventing suppliers.
Q2Why is approving a plan once not always enough for risky tasks?Reveal
The plan may change after approval through replanning, and the exact details (recipient, amount, text) are often only known at the time of action. For high-risk actions, confirm the final concrete action too, or allow only replans that do not add new write steps without fresh approval.
Questions people ask
Is chain-of-thought the same as planning?
They are related. Chain-of-thought is the model writing out reasoning steps before an answer. Planning, in agents, means producing a list of actions to take over time, often stored and tracked by code. An agent can use chain-of-thought inside each step.
Should the planner and the executor be different models?
They can be. Some teams use a stronger model for planning and a cheaper, faster model for simple steps. Measure it: the saving only matters if the cheaper model still completes the steps correctly.
How do I know when to replan?
Common triggers: a step failed after its retries, a tool result contradicts an assumption in the plan, or the user changed the goal. You can also ask the model after each step "does the remaining plan still make sense?", but limit how often it may change the plan.
Do reasoning models still need explicit plans?
Models trained to reason at length often plan well inside one answer. For long tasks with many tool calls, an explicit checklist in your code still helps: you can track progress, show it to people and resume after a crash.
Lesson test
5 questions. Get 3 right (60%) to pass and complete this lesson.