Plan-and-Execute
Also known as: planner–executor, plan-then-act, task decomposition
- Who decides
- The model
- Shape
- Loop
Intent
Ask a strong model to write the whole list of steps first, as a plan the system stores, and run those steps with cheaper machinery: tool calls, a small model or plain code. The strong model is called again only to read the results and either answer or write a revised plan for what is left.
Problem
You are building a research assistant on top of web search. A user asks: “For each of the three largest EU car makers, find 2024 and 2023 revenue, compute growth, and give me a ranked table with sources.”
A plain ReAct loop on a frontier model handles this one action at a time: search maker 1, read, search maker 1 again for 2023, read, and so on. That is about seven calls to the big model, run strictly one after another. Three things go wrong:
- Every step pays for the whole history. Each call re-sends the growing transcript, full of raw search results, to the most expensive model. Cost and waiting time grow with every step.
- The model only looks one step ahead. It reasons about the next search, not about the request as a whole, so the path wanders and some searches are repeated.
- The request gets buried. After a few steps the user’s words sit far back in the context, under pages of search output. The final table leaves out the third maker and computes growth from the wrong base year.
What is missing is a list of steps, written once while the whole request is still in view.
Solution
Split the agent into a planner that decides the steps once, executors that carry them out, and a replanner that looks at the results. The plan is a stored object, such as a JSON list or a graph of steps, that plain code can check, schedule and show to a person before anything runs.
On the car-maker request, a run looks like this:
- Plan. One call to the strongest model gets the request and the list of tools, and returns six steps: (a) find the three largest EU car makers; (b, c, d) for each maker, find 2024 and 2023 revenue with a source; (e) compute growth; (f) rank and format. Steps b to d depend on a, and not on each other.
- Check the plan. Plain code confirms that the plan parses, uses only known tools, has no cycles and stays under the step budget. A person could review or edit it here.
- Execute. A scheduler runs a, then sends b, c and d at the same time. Each executor, a search tool plus a small model, sees only its own question and the output of step a, not the full history.
- Replan. A strong model reads the request, the plan and the short results. Maker 2’s 2023 figure is missing, so it returns a new plan with only that step: search maker 2’s 2023 annual report.
- Answer. The new step runs and the replanner sees all six figures. It writes the ranked table, and the run ends.
The task now takes three calls to the big model instead of about seven, and the “three makers” requirement is pinned in a step list instead of buried in a transcript. The nearest pattern, ReAct, lets the model choose each action after seeing the last result; here the model decides most of the steps up front, and gets control back only at the points you choose.
Structure
Hover over a number, or tap it, to read what it is.
- Planner. Usually the strongest model. It gets the objective, a short description of each tool and the budgets, and returns a plan in a strict format.
- Plan. The steps still to run, their dependencies and the finished steps, kept outside the prompt so it survives long runs. Plain code rejects unknown tools, cycles and plans over budget before anything runs.
- Scheduler. Plain code with no model. It picks every step whose dependencies are done, fills in the outputs those steps need, and dispatches them.
- Executors. Each runs one step and returns a short result. An executor can be a tool call, a small model or a small tool-calling agent.
- Step results. Stored by step id, with errors kept as values, so one failed step does not crash the run.
- Replanner. Reads the objective, the plan and the results, and returns either the final answer or a new plan holding only the steps still needed. A limit on replans stops it from looping.
Use it when / Avoid it when
Use it when
- You can guess the shape of the task from the request. Multi-part questions, research reports and gather-then-compute jobs can be planned before the first search.
- Many steps are independent. They can run at the same time, which cuts the waiting.
- Big-model cost matters. Xu et al. report that ReWOO, a plan-once version, used 1,986 tokens per HotpotQA question against 9,795 for a ReAct agent, with slightly better accuracy.
- Someone must approve the work before it runs. A written plan is easy to review before an email goes out or code changes.
Avoid it when
- Each step depends on what the last one showed. Use ReAct: debugging an unknown failure or browsing a website cannot be planned ahead.
- The task takes one to three tool calls. Use a ReAct loop or a single call, because the planning call would be pure overhead.
- The steps are always the same. Use a prompt chain, with the steps fixed in code.
- Each subtask needs its own agent and context. Use Orchestrator–Workers, which hands each part to a separate agent.
How it fails
- A plan built on a wrong assumption
-
The planner assumes a figure will be in the search results, and every later step faithfully runs a plan that cannot work.
Mitigation: let executors report that an assumption was false, and replan when they do.
- Running on garbage
-
Step 2 fails, steps 3 to 6 run on its empty output, and the final answer comes out confident anyway.
Mitigation: store errors as results, skip steps whose inputs failed, and let the replanner see them before answering.
- Replanning without end
-
The replanner keeps writing similar plans, or repeats steps that already succeeded, and the cost doubles.
Mitigation: cap the number of replans, and remove completed steps from each new plan in code.
- Over-planning
-
A ten-step plan for a two-step request, where planning takes longer than the work.
Mitigation: send simple requests through Routing to a direct answer before they reach the planner.
Related patterns
- ReAct (tool-use loop): decides after every observation, where Plan-and-Execute decides most steps up front; an executor is often a small ReAct loop.
- Prompt Chaining: the developer fixes the steps at design time, while here the model writes the chain at run time.
- Orchestrator–Workers: also splits the task, but hands the parts to separate agents with their own context; the two are often combined.
- Human-in-the-Loop: approving or editing the plan before it runs is the most common place for a person to step in.
Try it
Describe the requests your agent handles, the tools it can call and its limits. The generator writes three prompts, for the planner, the executor and the replanner, plus the checks your code should run on each plan.
Open the generator on this pattern
Further reading
- Plan-and-Execute Agents (LangChain, 2024): three planning designs side by side, with the drawbacks of each.
- ReWOO: Decoupling Reasoning from Observations (Xu et al., 2023): the plan-once design and its token measurements.
- An LLM Compiler for Parallel Function Calling (Kim et al., 2023): plans as graphs, parallel steps, and where failures come from.