Planning Pattern (Plan, then Execute)
Make the whole to-do list first, then start ticking it off
Think of planning a road trip. Before you turn the key, you write the full route: fuel up, drive to the first city, eat lunch, drive to the second city. Then you simply follow that list. The Planning pattern (often called Plan-and-Execute ) works the same way: the agent first writes a complete step-by-step plan , and then executes the steps one by one.
Key points
- Planning = make a full plan first, THEN execute it.
- Contrast with ReAct, which decides one step at a time.
- Great for multi-step tasks where the steps are knowable upfront.
- You can re-plan if reality breaks the original plan.
The one-line definition
In the Planning pattern, the agent uses the LLM to generate a complete, ordered list of steps to reach the goal, and then an executor carries out each step in turn (often re-planning if a step fails or new info appears).
Note: First decide ALL the steps, then do them in order.
Plan-and-Execute at a glance
┌──────────────────────────────┐ GOAL ─────► │ PLANNER │ │ "break the goal into an │ │ ordered list of steps" │ └───────────────┬──────────────┘ │ produces a plan ▼ ┌──────────────────────────────┐ │ PLAN: 1) ... 2) ... 3) ... │ └───────────────┬──────────────┘ │ ▼ ┌──────────────────────────────┐ │ EXECUTOR │ │ do step 1 → step 2 → step 3 │ ──► ✅ DONE └──────────────────────────────┘
ReAct vs Planning (the key contrast)
ReAct (decide as you go) PLANNING (decide upfront) ───────────────────────── ──────────────────────────
think → act → observe make full plan ▲ │ 1) ... └───────────┘ 2) ... (one step at a time, 3) ... re-decides each turn) │ ▼ execute 1, 2, 3 in order
Best when steps are Best when steps are mostly unknown / change a lot knowable in advance
The 2 stages of Planning
- Planner — Breaks the goal into a clear, ordered list of smaller steps before any work begins. Example: "1) search flights 2) compare prices 3) book cheapest 4) email receipt"
- Executor — Carries out each step in order, calling tools as needed. Example: Runs step 1, stores the result, moves to step 2.
- Re-plan (optional) — If a step fails or new info appears, the planner adjusts the remaining steps. Example: "Flight sold out → re-plan: search next-day flights instead."
A tiny code example (read it like English)
First we ask the LLM for a list of steps. Then we loop over those steps and execute each one. Notice the plan is made once upfront, before any execution starts.
plan = llm( # PLANNER
f"Break this goal into ordered steps:\n{goal}")
steps = plan.as_list() # e.g. ['search', 'compare', 'book']
results = []
for step in steps: # EXECUTOR
outcome = run_step(step, results) # do the step
results.append(outcome)
if outcome.failed: # optional re-plan
steps = llm(f"Step failed: {outcome}. Re-plan rest.")
steps = steps.as_list()
print("Goal complete:", results[-1])
▶ Try it: make a plan, then execute it
Change the goal and write your own plan steps, then Run.
goal = "make a cup of tea"
# STEP 1: the planner makes the full plan first
plan = ["boil water", "add tea leaves", "add milk", "pour into cup"]
print("GOAL:", goal)
print("\nPLAN:")
for i, step in enumerate(plan, start=1):
print(f" {i}. {step}")
# STEP 2: the executor runs each step in order
print("\nEXECUTING:")
for step in plan:
print(" done ->", step)
When should you plan upfront?
| Scenario | Recommendation | Why |
|---|---|---|
| A long task with many dependent steps you can foresee | ✅ Use Planning | A clear plan keeps the agent organised and on track. |
| You want a visible plan a human can approve first | ✅ Use Planning | The plan can be reviewed before any action is taken. |
| Each step's outcome heavily changes what to do next | ❌ Prefer ReAct | An upfront plan goes stale fast; deciding step-by-step adapts better. |
| A one-shot question with no real steps | ❌ Plain LLM call | There is nothing to plan. |
Beginner Planning mistakes
| Mistake | Consequence | Fix |
|---|---|---|
| Following a stale plan when reality has changed. | The agent does pointless or wrong steps. | Allow re-planning when a step fails or new information appears. |
| Making the plan too vague ("do research"). | Steps are not executable; the agent flounders. | Ask for concrete, single-action steps the executor can actually run. |
| Using Planning for unpredictable, fast-changing tasks. | Constant re-planning; you'd be better off with ReAct. | Match the pattern to the task: plan when steps are knowable, ReAct when they're not. |
Remember these 3 lines
- Planning = make the full plan first, then execute it in order.
- ReAct decides step-by-step; Planning decides everything upfront.
- Let the agent re-plan when a step fails or new info shows up.
Key takeaways
- The Planning (Plan-and-Execute) pattern creates a full ordered list of steps first, then executes them.
- It contrasts with ReAct, which decides one step at a time as it observes results.
- Use Planning when steps are knowable upfront or a human should approve the plan.
- Allow re-planning so the agent can recover when a step fails or new info arrives.
Frequently Asked Questions
What is Planning Pattern?
Think of planning a road trip. Before you turn the key, you write the full route: fuel up, drive to the first city, eat lunch, drive to the second city.
How does Planning Pattern work?
In the Planning pattern, the agent uses the LLM to generate a complete, ordered list of steps to reach the goal, and then an executor carries out each step in turn (often re-planning if a step fails or new info appears).
What are the key takeaways about Planning Pattern?
The Planning (Plan-and-Execute) pattern creates a full ordered list of steps first, then executes them. It contrasts with ReAct, which decides one step at a time as it observes results. Use Planning when steps are knowable upfront or a human should approve the plan. Allow re-planning so the agent can recover when a step fails or new info arrives.
Related topics
Practice this on DevInterviewMaster
Read the full Planning Pattern (Plan, then Execute) breakdown with interactive demos, quizzes, and Hinglish notes.
800+ system-design, LLD, coding, and design-pattern topics. Unlock everything with Pro (₹499, one-time) or Ultimate (₹999, one-time) — lifetime access, no subscription.