Planning
Module 3 — Planning 🗺️
Goal of this module: Learn how an agent turns a big, fuzzy goal (“plan my trip to Tokyo”) into a clear sequence of small, doable steps — and the different strategies it can use to do that well.
3.1 Why planning matters
Imagine you’re asked: “Organize a birthday party for 20 people next Saturday.”
You don’t just start randomly. In your head you break it down: pick a venue, send invites, order a cake, buy decorations, plan food. That breakdown is a plan. Without it, you’d forget the cake and double-book the venue.
Agents are the same. For anything beyond a one-step task, an agent that plans first is far more reliable than one that just reacts. Planning is the difference between “search, then panic” and “here are the 5 steps; let’s do them in order.”
Definition: Planning is the agent’s ability to decompose a goal into an ordered set of sub-tasks, and decide how to tackle them.
3.2 Decomposition: the core skill
Decomposition = breaking a big task into smaller tasks. This is the heart of planning.
Example goal: “Write a blog post about electric cars.”
A planning agent decomposes it like this:
Goal: Write a blog post about electric cars
Plan:
1. Research current EV market facts (use web_search)
2. Find 3 pros and 3 cons of EVs
3. Outline the post (intro, pros, cons, conclusion)
4. Write each section
5. Review for clarity and accuracy
6. Produce the final post
Now each step is small and clear. The agent can do them one at a time and check progress. Notice that some steps need tools (research) and some are pure thinking (outline). Good plans mix both.
3.3 Two big styles of planning
There are two main moments an agent can plan:
(a) Plan-first (a.k.a. “decompose then execute”)
The agent writes out the whole plan up front, then executes each step.
1. Make full plan → 2. Do step 1 → 3. Do step 2 → ... → Done
- ✅ Pros: Clear roadmap, easy to follow, easy for a human to review before anything happens.
- ❌ Cons: Rigid. If reality differs from the plan (a search returns nothing useful), the agent may stubbornly follow a bad plan.
Best for: Tasks where the steps are predictable (e.g., “fill out this form,” “generate a report with these sections”).
(b) Plan-as-you-go (a.k.a. “interleaved” or “ReAct-style”)
The agent plans one step at a time, deciding the next action based on what just happened. This is the think→act→observe loop from Module 1.
Think next step → Act → Observe → Think next step → Act → ...
- ✅ Pros: Flexible. Adapts to surprises. If a search fails, it tries a different approach.
- ❌ Cons: Can wander, get stuck in loops, or take more steps than needed.
Best for: Open-ended, unpredictable tasks (research, debugging, exploration).
(c) The best of both: plan, then adapt
Strong agents often make a rough plan first, then adapt it as they go. They re-plan when something unexpected happens. This is called re-planning or dynamic planning, and it’s what skilled humans do too. You plan the party, but when the venue cancels, you adjust.
3.4 Planning strategies you should know (by name)
These are named techniques you’ll hear experts mention. Each is just a smarter way to plan.
Chain-of-Thought (CoT)
The model reasons step by step in plain language before acting. “First I need X, because Y, so I’ll do Z.” Simple but powerful. (Deep dive in Module 5.)
Decomposition / Task lists
The agent literally writes a to-do list of sub-tasks and works through it, checking off items. Many real agents keep an explicit task list in their context.
Tree of Thoughts (ToT)
Instead of one line of reasoning, the agent explores several possible plans like branches of a tree, evaluates them, and picks the best path.
Goal
/ | \
Plan A Plan B Plan C ← explore multiple options
| | |
eval eval eval ← score each
\
pick best ← follow the winner
- When useful: Hard problems with many possible approaches (puzzles, strategy, complex coding). More thorough but uses more time/tokens.
Least-to-most prompting
Solve the easiest sub-problems first, then use those answers to tackle harder ones. Like building a wall brick by brick.
Hierarchical planning
Make a high-level plan, then break each high-level step into its own sub-plan. Like an outline with sub-bullets.
High-level: 1. Research 2. Write 3. Publish
↓
Research breaks into: 1a. find sources 1b. extract facts 1c. verify
This mirrors how a manager plans at a high level and delegates the details — which is exactly how multi-agent systems (Module 8) work.
3.5 Re-planning: handling surprises
The real world breaks plans. A good agent notices when a step fails or returns surprising results and adjusts. This loop looks like:
Make plan → Execute step → Did it work?
│
┌── Yes ──────┘
▼
Next step
│
└── No → Re-plan (try a new approach)
Example: Agent plans to book a 7am flight. The booking tool says “sold out.” A bad agent gives up or repeats the same action. A good agent re-plans: “That flight is gone — let me find the next cheapest option.”
Expert habit: Always design agents to detect failure and re-plan, not just blindly continue. Build in a maximum number of steps so a confused agent doesn’t loop forever.
3.6 A worked example (full planning trace)
Goal: “Find me a highly-rated Italian restaurant near downtown open tonight, and tell me its phone number.”
PLAN (made up front):
1. Search for Italian restaurants downtown.
2. Filter by rating (4+ stars).
3. Check which are open tonight.
4. Get the phone number of the best option.
EXECUTE:
Step 1 → search("Italian restaurants downtown")
→ got 12 results.
Step 2 → filter by rating → 4 results above 4 stars.
Step 3 → check hours → 2 are open tonight.
Step 4 → Surprise! The top one's phone number is missing.
→ RE-PLAN: search the restaurant's name + "phone".
→ got the number.
RESPOND: "Bella Roma (4.6★) is open until 11pm. Phone: 555-0142."
Notice the agent planned, executed, hit a snag, and re-planned. That adaptability is the mark of a good planner.
3.7 Common planning mistakes (and fixes)
| Mistake | What it looks like | Fix |
|---|---|---|
| No plan | Agent flails, repeats actions | Force an explicit planning step in the prompt |
| Over-planning | 20-step plan for a 2-step task | Match plan depth to task complexity |
| Rigid plan | Follows a broken plan off a cliff | Allow re-planning on failure |
| Infinite loop | Same action forever | Set a max-step limit |
| Vague steps | ”Handle the data” (how?) | Make each step a concrete, doable action |
3.8 How to make an agent plan (prompt snippet)
You often trigger planning right in the system prompt:
Before taking any action, first write a short numbered plan
of the steps you'll take. Then execute the steps one by one.
If a step fails or returns unexpected results, revise your
plan before continuing. Stop after at most 10 steps.
That single instruction turns a reactive agent into a planning agent.
3.9 Check yourself ✅
- What does “decomposition” mean?
- What’s the difference between plan-first and plan-as-you-go?
- What is re-planning, and why is it important?
- Name one planning strategy that explores multiple options at once.
Answers
- Breaking a big goal into smaller, doable sub-tasks.
- Plan-first writes the whole plan up front then executes; plan-as-you-go decides each next step based on what just happened.
- Adjusting the plan when a step fails or surprises the agent — important because the real world rarely matches the original plan.
- Tree of Thoughts (ToT).
3.10 Summary
- Planning = decomposing a goal into ordered, doable steps.
- Two styles: plan-first (clear but rigid) and plan-as-you-go (flexible but can wander); best agents combine them and re-plan on surprises.
- Named strategies: Chain-of-Thought, task lists, Tree of Thoughts, least-to-most, hierarchical planning.
- Always allow re-planning and cap the number of steps to avoid loops.
- A single prompt instruction can turn a reactive agent into a planner.
Next up: Module 4 — Tool Use. Now that the agent has a plan, how does it actually do things in the world? 👉 04_Tool_Use.md