TAI BUI
Back to curriculum
BuildPython

ReWOO and Plan-and-Execute: Decoupled Planning

ReAct interleaves thought and action in one stream. ReWOO splits them: plan once up front, then execute. On HotpotQA that bought about 5x fewer tokens and +4 accuracy, and the planner can be distilled into a 7B model. Plan-and-Execute generalized the idea, and Plan-and-Act scaled it to web navigation.

TIME: ~60 minutesPREREQUISITES: Phase 14 · 01 (Agent Loop)

Learning Objectives

  • Explain why ReWOO's Planner / Worker / Solver split saves tokens and improves robustness over ReAct's interleaved loop.
  • Implement a plan DAG, a dependency-ordered executor, and a solver that composes worker outputs, all in stdlib.
  • Decide when a task should run as plan-then-execute vs interleaved ReAct, using the 2026 "five workflow patterns" framing (Anthropic).
  • Recognize when Plan-and-Act's synthetic plan data is needed for long-horizon web or mobile tasks.

The Problem

ReAct's interleaved thought-action-observation loop is simple and flexible, but every tool call has to carry the full prior context, including each earlier thought. Each step's prompt grows linearly with depth, so total tokens billed across a run grow quadratically. Failures are worse. When a tool breaks mid-loop, the model has to re-derive the whole plan from one error observation.

ReWOO (Xu et al., arXiv:2305.18323, May 2023) bets the other way: plan everything up front, fetch evidence in parallel, compose the answer at the end. That's one LLM call to plan, N tool calls for evidence (which can run in parallel), and one LLM call to solve. You give up flexibility because the plan is static. In return you get far better token efficiency and failures you can actually locate.

Warm-up0/3
1. Why does the total token cost of a ReAct run grow quadratically with depth?Warm-up
2. Task B needs the output of task A. In what order must a scheduler run them?Warm-up
3. What is guaranteed in a directed acyclic graph (DAG)?Warm-up
Check: The Problem0/1
1. What does ReWOO give up in return for its token savings and failures you can locate?Explain

The Concept

ReWOO (Reasoning WithOut Observation) is an agent pattern that separates planning from tool execution. A planner writes the full plan before any tool runs, workers carry it out, and a solver turns the collected evidence into an answer. Plan-and-Execute and Plan-and-Act are descendants of it.

The three roles

Planner:  user_question -> [plan_dag]
Workers:  [plan_dag]     -> [evidence]        (tool calls, possibly parallel)
Solver:   user_question, plan_dag, evidence -> final_answer

The planner produces a DAG. Each node names a tool, its arguments, and which earlier nodes it depends on, using references like #E1 and #E2. Workers execute the nodes in topological order. The solver stitches the results together.

Why 5x fewer tokens

ReAct's prompt grows linearly with step count, which makes cumulative tokens across a run grow quadratically. At step 10, the prompt holds thought 1, action 1, observation 1, thought 2, action 2, observation 2, and so on, and every intermediate step also repeats the original prompt.

ReWOO pays for one planner prompt (large), N small worker prompts (just the tool call, no chain), and one solver prompt. On HotpotQA the paper measures roughly 5x fewer tokens with +4 absolute accuracy.

Why it is more robust

If worker 3 fails in ReAct, the loop has to reason its way out of the error mid-stream. In ReWOO, worker 3 returns an error string, and the solver sees it next to the original plan and can degrade gracefully. Failure localization is per node, not per step.

Planner distillation

The paper's second result follows from the first. The planner never sees observations, so you can fine-tune a 7B model on planner outputs from a 175B teacher. The small model plans and the big model isn't needed at inference. This is standard practice now, and many 2026 production agents pair a small planner with a big executor, or the reverse.

Plan-and-Execute (LangChain, 2023)

The LangChain team's August 2023 post turned ReWOO into a named pattern: Plan-and-Execute. An up-front planner emits a step list, an executor runs each step, and an optional replanner can revise the plan after seeing results. Because the replanner pulls observations back into planning, this sits closer to ReAct than ReWOO does, but it keeps most of the token savings.

Plan-and-Act (Erdogan et al., arXiv:2503.09572, ICML 2025)

Plan-and-Act scales the pattern to long-horizon web and mobile agents. Its key contribution is synthetic plan data: a labeled trajectory generator produces training examples where the plan is explicit. That data fine-tunes planner models that keep working past 30-50 steps on WebArena-like tasks, where a single ReAct trajectory loses coherence.

When to pick which

PatternWhen
ReActShort tasks, unknown environment, need reactive exception handling
ReWOOStructured tasks with known tools, token-sensitive, parallelizable evidence
Plan-and-ExecuteLike ReWOO but with replanning after partial execution
Plan-and-ActLong-horizon (>30 steps), web/mobile/computer-use
Tree of ThoughtsSearch is worth paying for (Lesson 04)

Anthropic's Dec 2024 guidance is to start with the simplest thing that works. If the task is one tool call plus a summary, don't build ReWOO. If it's a 40-step research assignment, don't run ReAct alone.

Check: The Concept0/18
1. What is the three-role split that defines ReWOO?Define
2. What distinguishes LangChain's Plan-and-Execute pattern from plain ReWOO?Define
3. What is Plan-and-Act?Define
4. What does a placeholder like #E1 inside a ReWOO plan node mean?Define
5. What is planner distillation?Define
6. What headline numbers does the paper report for ReWOO vs ReAct on HotpotQA?Define
7. What does the Solver receive and produce in ReWOO?Define
8. Why are ReWOO's worker prompts small compared to ReAct's late-step prompts?Explain
9. Why does ReWOO localize failures better than ReAct?Explain
10. What does ReWOO's planner distillation result imply for production agents?Explain
11. Why does Plan-and-Execute sit closer to ReAct than ReWOO does?Explain
12. Why does Plan-and-Act rely on synthetic plan data?Explain
13. Which task shape best fits Plan-and-Act over plain ReWOO?Apply
14. Per the lesson's decision table, when should you reach for ReWOO instead of ReAct?Apply
15. A team adds a replanner after every step and token use climbs back toward ReAct levels. What happened?Analyze
16. A task is one tool call followed by a summary. Which design fits?Design
17. A structured research job has three independent lookups, known tools, a tight token budget and a cheap model available. Which design fits?Design
18. You must automate a 50-step web task, and a ReAct trajectory loses coherence midway. What should you add?Design

Build It

code/main.py implements a toy ReWOO:

  • Planner: a scripted policy that emits a plan DAG from a prompt.
  • Worker: dispatches each node's tool call through the registry.
  • Solver: scripted composition that reads the evidence and produces a final answer.
  • Dependency resolution: references like #E1 get replaced with earlier worker outputs.

The demo answers "What is the population of the capital of France, rounded to millions?" with a two-step plan. Step one looks up the capital, step two looks up the population, then the solver composes the answer.

Run it:

python3 code/main.py

The trace prints the full plan first, then the worker results, then the solver's composition. It also prints a rough character count, so compare that against an interleaved ReAct run of the same task. ReWOO wins on structured work like this.

Check: Build It0/10
1. What does a DAG executor do with a plan?Define
2. Why must the executor dispatch nodes in dependency order instead of simply the listed order?Explain
3. Why does the planner write #E1 in the second step instead of the capital's actual name?Explain
4. The demo's E2 is search with query 'population of #E1', and E1 returned 'Paris'. What query does the worker dispatch for E2?Apply
5. In the demo, E2 returns '11.2 million metro' and E3 calls round_million on it. What does E3 hold?Apply
6. A plan lists E3, E1, E2. E2's args reference #E1 and E3's args reference #E2. In what order does run_workers dispatch them?Apply
7. A plan node calls a tool named 'weather' that was never registered. What does ToolRegistry.dispatch do?Apply
8. resolve_references is called on 'population of #E7' when evidence only has E1 and E2. What does it return?Apply
9. run_workers raises RuntimeError('cyclic plan or unresolved reference'). Which cause fits?Analyze
10. In run_react_mock, the character total grows much faster than ReWOO's as trajectories lengthen. What accounts for it?Analyze

Use It

LangGraph ships Plan-and-Execute as a recipe: create_react_agent for ReAct, custom graphs for plan-execute. CrewAI's Flows encode the pattern directly. You define the tasks up front and the Flow DAG executes them. Plan-and-Act's synthetic-data approach is still mostly research, but its runtime pattern, an explicit plan DAG, already ships in production through LangGraph and CrewAI Flows.

Check: Use It0/1
1. Where does the Plan-and-Execute pattern actually ship in production frameworks, per the Use It section?Explain

Ship It

outputs/skill-rewoo-planner.md generates a ReWOO plan DAG from a user request and a tool catalog. Before handing off to an executor, it validates the plan: acyclic, every reference resolved, every tool present.

Check: Ship It0/2
1. Which problems can the planner skill's validation catch before any tool runs?Explain
2. A plan passes the acyclic and reference checks, yet step 3 fails because it parses a field the tool never returns. Which property of ReWOO explains this?Analyze
Author's Note

Most plan-and-execute failures come from the plan, not the executor. A planner that can't see observations will happily write step 3 against a tool output it has guessed wrong, and the DAG looks perfectly valid right up until a worker runs. Validate the plan hard (the Ship It skill does) and keep the tool catalog small enough that the planner can't invent a call. If you find yourself bolting on replanning after every step, you've rebuilt ReAct with extra prompts. At that point just use ReAct.

Exercises

  1. Parallelize worker execution for independent plan nodes. What does it buy you on a 6-node DAG with 2 parallel groups?
  2. Add a replanner node that fires if any worker returns an error. What is the smallest change that turns ReWOO into Plan-and-Execute?
  3. Replace Planner with a small model (7B class) and keep Solver on a frontier model. Compare end-to-end quality. Where does the split fail?
  4. Read Section 4 of the ReWOO paper on planner distillation and reproduce the 175B -> 7B result conceptually. What training data do you need, and how do you score plan quality?
  5. Port the toy to Plan-and-Act's trajectory shape, where the plan is a sequence instead of a DAG. What tradeoffs change?

Key Terms

TermWhat people sayWhat it actually means
ReWOO"Reasoning without observations"Plan, then fetch evidence in parallel, then solve. No observations appear in the planning prompt
Plan-and-Execute"LangChain's plan-execute pattern"ReWOO with an optional replanner node after execution
Plan-and-Act"Scaled plan-execute"Explicit planner/executor split with synthetic plan training data for long-horizon tasks
Evidence reference"#E1, #E2, ..."Plan-node placeholder substituted with prior worker output at dispatch time
Planner distillation"Small planner, big executor"Fine-tune a small model on planner traces from a large teacher
Token efficiency"Fewer round trips"5x fewer tokens on HotpotQA vs ReAct in the paper
DAG executor"Topological dispatcher"Runs plan nodes in dependency order, parallel at each level

Further Reading

Code

Ships With