Contents

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:

What is missing is a list of steps, written once while the whole request is still in view.

A ReAct agent answers the car-maker request with seven sequential big-model calls whose context grows each time, and the final table forgets one maker and uses the wrong base year.User request3 makers, 2 yearseach call re-sends every earlier search result1234567big-model calls, one after anotherFinal tablethird maker missingwrong base year
Scroll to see all of it.
Each bar is one call to the big model and its height is the context it carries, so cost grows with every step while the request’s details end up buried.

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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

The objective goes to a planner that writes a plan; a scheduler runs ready steps on parallel executors; their results go to a replanner, which either answers or sends a revised plan with only the remaining steps back to the plan.revised plan:remaining steps onlyrespondObjectivePlannerstrong modelPlana. find the 3 makersb–d. revenues (after a)e. growth, f. tableSchedulercode, no LLMExecutormaker 1Executormaker 2Executormaker 3Step results by idReplanneranswer or new planAnswer123456
Scroll to see all of it.

Hover over a number, or tap it, to read what it is.

Solid arrows carry instructions, dashed arrows carry results. The accent arrow is the loop: the replanner sends back a plan with only the remaining steps, or answers.
  1. 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.
  2. 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.
  3. Scheduler. Plain code with no model. It picks every step whose dependencies are done, fills in the outputs those steps need, and dispatches them.
  4. 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.
  5. Step results. Stored by step id, with errors kept as values, so one failed step does not crash the run.
  6. 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

Avoid it when

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

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.

Further reading