Articles

Plan-and-Execute Agents: How LLM Agents Plan Ahead

Plan-and-execute agents have an LLM write a multi-step plan first, then run each step. How the pattern works, how it compares to ReAct, and when to use it.

Chisato Chisato · · 5 min read
A laptop showing code with an AI assistant panel

A plan-and-execute agent is an LLM agent architecture that splits work into two phases: a planner model writes an explicit, ordered list of steps for the whole task up front, and an executor carries out those steps one at a time, usually with tools. After execution, the agent can replan based on what it learned. The pattern trades some flexibility for predictability, lower cost on long tasks, and a plan a human can read before anything runs.

Why separate planning from acting?

The most common agent loop is the ReAct pattern: the model thinks, takes one action, observes the result, and repeats. ReAct is flexible because it decides each step with fresh information. Its weakness is that it never commits to a strategy. On long tasks it can wander, repeat itself, or lose the original goal as the transcript grows and the early instructions get diluted inside the context window.

Plan-and-execute forces the model to reason about the whole task before touching anything. That has a few concrete benefits:

  • Global coherence. The plan is a single artifact that keeps the goal in view. Each executor step is framed by it.
  • Cheaper execution. Planning needs a capable model; executing a well-specified step often does not. You can run the planner on a large model and the executor on a smaller, faster one.
  • Inspectability. A plan is something a person or a policy check can approve before side effects happen.
  • Parallelism. Independent steps in a plan can run concurrently.

How the loop works

A typical implementation has three components.

1. Planner. Given the user’s goal and a description of available tools, the planner outputs a structured plan — usually a numbered list or a JSON array of steps, each with a description and sometimes the tool it expects to use. Using structured outputs here makes the plan easy to parse and validate.

[
  {"id": 1, "task": "Find the config file that sets the API timeout"},
  {"id": 2, "task": "Read the current timeout value", "depends_on": [1]},
  {"id": 3, "task": "Change the timeout to 30 seconds", "depends_on": [2]},
  {"id": 4, "task": "Run the test suite and report failures", "depends_on": [3]}
]

2. Executor. For each step, an executor — often itself a small ReAct loop with tool access through function calling — completes that one task and returns a result. The executor sees the step, the overall goal, and the results of earlier steps, but not necessarily the full history of every prior tool call. Keeping its context narrow is part of the point.

3. Replanner. After a step (or after all steps), the replanner looks at the original goal, the plan, and the results so far. It decides whether to finish, continue with the remaining steps, or rewrite the rest of the plan. Without this stage the pattern is brittle: real tasks rarely go exactly as planned, and a step that fails or reveals new information should change what happens next.

Plan-and-execute vs ReAct

ReActPlan-and-execute
When strategy is decidedOne step at a timeUp front, revised by replanning
Model calls per stepOne large-model callSmall executor calls, occasional planner calls
Handles surprisesNaturally, every stepOnly at replan points
Long-task coherenceCan driftAnchored to the plan
Human reviewHard; actions happen immediatelyEasy; approve the plan first
Parallel stepsNot by defaultPossible when steps are independent
Best forShort, exploratory tasksMulti-step tasks with a clear structure

Neither is strictly better. Many production agents are hybrids: a plan-and-execute outer loop with ReAct executors inside each step.

Variations on the pattern

DAG planning. Instead of a linear list, the planner emits a dependency graph. Steps with no unmet dependencies run in parallel, and a scheduler joins results. This is how “compile the plan, then execute it” systems get large speedups on tasks like gathering data from several sources.

Plan with variable references. The planner writes steps that reference earlier outputs symbolically (for example, “summarize the result of step 2”), and the executor substitutes the actual values. This lets the whole plan be generated in one call without the planner seeing any tool output.

Hierarchical planning. A top-level planner breaks the goal into subgoals, each handed to its own sub-agent with its own planner. This shades into multi-agent systems, where orchestration and handoffs become the main design concern.

Where it goes wrong

The pattern has failure modes worth designing around.

  • Over-planning. The planner invents steps for problems that do not exist yet. A task that needs exploration first — “figure out why the build is failing” — cannot be planned in detail before you look. Let the first step be investigation and replan afterward.
  • Stale plans. If replanning is rare, the agent keeps executing steps whose premises are no longer true. Replan after any failed step at minimum.
  • Lossy handoffs. Executors that only see a one-line task description may lack context the planner had. Pass the goal and relevant prior results along with each step.
  • False confidence. A tidy plan looks authoritative, but it is still model output. It can reference files that do not exist or tools the agent does not have. Validate plan steps against the real tool list before running them.

Security matters too. A plan approved by a human is a useful control point, but an executor that reads untrusted content — web pages, emails, repository files — can still be steered by prompt injection mid-step. Plan approval is not a substitute for limiting what each executor’s tools can do; see AI agent sandboxing for that side of the problem.

When should you use it?

Plan-and-execute fits when the task has recognizable structure, involves many steps, and benefits from review before action: data pipelines, multi-file code changes, research that pulls from several sources, or workflows with costly or irreversible side effects. It is overkill for a single question answered with one search, and it struggles with tasks whose shape is unknown until you start poking at them.

A practical heuristic: if you could write the checklist yourself before starting, an agent can too, and plan-and-execute will likely be cheaper and more reliable than a free-running loop. If you would have to start working to find out what the checklist even is, begin with ReAct and add planning once the problem’s shape is clear.

The takeaway

Plan-and-execute agents write a plan first and carry it out step by step, replanning when reality diverges. Compared with ReAct, they stay more coherent on long tasks, let you run cheaper models for execution, and give humans a clear point to approve work before it happens. Build in frequent replanning, pass enough context to each executor, validate plans against real tools, and treat the plan as a draft rather than a guarantee.

Chisato Chisato · · 4 min read

What Is Context Rot in LLMs?

Context rot is the drop in an LLM's accuracy and reliability as the amount of text in its context window grows, even when the window technically fits it.

#AI #LLMs #Agents