Skip to content
AgenticAIWiki
  1. Learn
  2. Part 9
  3. 47. Plan-and-execute and ReWOO
  4. 47.1

Lesson 47.1 · 1 of 5 · 5 min read · Reviewed 24 Nov 2026

Planning up front

By the end, you can

  • Explain plan-and-execute.
  • Know when planning up front beats ReAct.

The shape

Planner (strong model):
  1. Export last month's orders
  2. Group refunds by reason
  3. Draft a summary with the top 3 reasons
  4. Email the summary to finance          <- needs approval

Executor(s): run step 1, step 2, step 3 ... report results

Strengths

  • Reviewable: a person can approve or edit the plan before anything happens.
  • Predictable: you know roughly how many steps and how much it costs.
  • Cheaper execution: each step is narrow, so a smaller model can often do it (71.2).
  • Parallel steps: independent steps can run at the same time.

Weaknesses

  • Plans made before seeing data can be wrong. If step 1 shows there were no refunds, steps 2 to 4 are pointless.
  • Long plans go stale. Fix with replanning (47.3).

ReAct vs plan-and-execute

ReAct Plan-and-execute
Decides steps One at a time Mostly up front
Adapts to surprises Naturally Through replanning
Easy to review in advance No Yes
Cost predictability Lower Higher

Many real systems mix them: plan the big steps, then use a small ReActReAct: An agent pattern that interleaves reasoning steps and actions (tool calls), using each observation to plan the next step. loop inside each step.

Key points

  • Plan-and-execute splits the work: a planner writes the steps, then executors carry them out.
  • Planning up front gives structure, predictable cost and a plan humans can review.
  • It's weaker when early results should change the plan, so add replanning.
  • Executors can be cheaper models, since each step is narrow.
Hands-on labRuns in the Playground

Split a task into plan and execute

Separate planning from execution and see the reviewability and cost benefits.

You will have: A plan-and-execute script that prints a reviewable plan, runs it and compares executor costs.

Steps

  1. Run the starter: it prints the plan but executes nothing.
  2. Write execute() to match each step to its executor and run it.
  3. Print the credits for the run with large and with small executors.
  4. Change one executor to return something surprising and note that the plan does not adapt (that is 39.3's job).

Done when

  • The plan prints in full before any step runs.
  • All 4 steps execute and print their results.
  • Small executors cost 14 credits against 50 for large ones.

Open in the Playground No API key needed.

Starter code (Python)
# Plan-and-execute: a planner writes the steps once, then narrow executors run them.
PLANNER_CREDITS = 10   # illustrative cost of one call to a large model
LARGE, SMALL = 10, 1   # illustrative cost per executor step on each model size


def planner(goal):
    """Simulated planner: returns the full plan before anything runs."""
    return ["fetch invoice 881", "fetch payment method for customer 42",
            "compare card expiry with due date", "draft a reply to the customer"]


EXECUTORS = {
    "fetch invoice": lambda s: {"invoice": 881, "due": "2026-10-01"},
    "fetch payment": lambda s: {"card": "expired 2026-09"},
    "compare card": lambda s: "card expired before the due date",
    "draft a reply": lambda s: "Your card expired, so the payment failed. Please update it.",
}


def execute(plan):
    results = []
    # TODO: for each step, find the executor whose key the step starts with, run it, print it, keep the result
    return results


plan = planner("Explain why invoice 881 is overdue")
print("plan:", len(plan), "steps (a person can review this before anything runs)")
for i, s in enumerate(plan, 1):
    print(f"  {i}. {s}")
results = execute(plan)
print("executed:", len(results), "steps")
# TODO: print the credits for the whole run with LARGE executors and with SMALL executors
Show a solution
# Plan-and-execute: a planner writes the steps once, then narrow executors run them.
PLANNER_CREDITS = 10   # illustrative cost of one call to a large model
LARGE, SMALL = 10, 1   # illustrative cost per executor step on each model size


def planner(goal):
    """Simulated planner: returns the full plan before anything runs."""
    return ["fetch invoice 881", "fetch payment method for customer 42",
            "compare card expiry with due date", "draft a reply to the customer"]


EXECUTORS = {
    "fetch invoice": lambda s: {"invoice": 881, "due": "2026-10-01"},
    "fetch payment": lambda s: {"card": "expired 2026-09"},
    "compare card": lambda s: "card expired before the due date",
    "draft a reply": lambda s: "Your card expired, so the payment failed. Please update it.",
}


def execute(plan):
    results = []
    for step in plan:
        run = next(fn for key, fn in EXECUTORS.items() if step.startswith(key))
        out = run(step)
        print(f"  ran '{step}' -> {out}")
        results.append(out)
    return results


plan = planner("Explain why invoice 881 is overdue")
print("plan:", len(plan), "steps (a person can review this before anything runs)")
for i, s in enumerate(plan, 1):
    print(f"  {i}. {s}")
results = execute(plan)
print("executed:", len(results), "steps")
print("credits with large executors:", PLANNER_CREDITS + LARGE * len(plan))
print("credits with small executors:", PLANNER_CREDITS + SMALL * len(plan))
Quick checkUsers want to approve an agent's steps before anything changes in their systems. Which pattern fits?
How sure are you?
Pick an answer and how sure you are