Planning (deliberative) agent: write the plan, check it, then act
A planning agent works out a full list of steps before it does anything, then runs them in order. Use it when a task has several dependent stages and a mistake midway is costly.
Planning agent in 60 seconds
- What: an agent that writes a complete plan of steps and tools before it takes any action.
- How: write the plan, check it by a model or a person, run it step by step, and revise it if a step fails.
- Best for: multi-stage work with dependencies, such as reports, migrations, onboarding flows, and anything with costly side effects.
- Weak spots: plans can be wrong, go stale when the world changes, and cost extra time and tokens before any work happens.
- Research link: Plan-and-Solve prompting (Wang et al., 2023) shows the value of asking the model to split a task into subtasks before carrying them out.
Where this type fits
The types of AI agents hub groups agents by how they decide. The planning agent belongs to the first family, which covers reactive, planning, ReAct, plan-and-execute, reflexive, and learning agents. Within it, the planning agent is the pure deliberative case: think first, act second. The plan-and-execute agent is a more specific engineering of the same idea, with separate models for planning and doing.
The problem it solves
Consider an agent asked to prepare a customer data export for Acme. The work has stages: find which tables hold the data, remove fields that must not leave the company, produce the file, and send a download link. If the agent simply starts acting, it may produce the file before it has worked out which fields to remove. The order matters, and an agent that decides one step at a time can paint itself into a corner without noticing.
A second problem is that actions have side effects. Sending an email or deleting a record cannot be taken back. Without a plan, nobody can review what the agent intends to do until it has already done it. A written plan turns hidden intent into something a reviewer can read, question, and approve before anything changes.
A third problem is wasted effort. An agent that discovers halfway through that it lacks a permission, a tool, or a piece of data has already spent time and money on the earlier steps. Planning surfaces those gaps early. The agent can list the tools it needs, notice that one is missing, and stop or ask for help before the first action runs.
How it works
- Take the goal. The goal should say what done looks like, for example "produce a redacted export and send a link to the requester".
- Write the plan. The model breaks the goal into numbered steps. Each step names what to do, which tool to use, what it needs from earlier steps, and what a success looks like.
- Check the plan. A second model call, a rules check, or a person reviews it. The check looks for missing steps, wrong order, disallowed tools, and steps with risky side effects.
- Run it step by step. An executor works through the steps in order, passing each result to the next. Each step is validated before the next starts.
- Revise on failure. If a step fails or its result breaks an assumption, the agent goes back to the planning stage with the new facts and writes a revised plan, within a fixed limit on revisions.
- Return the result. The agent reports the outcome and, ideally, the plan it followed.
The key feature of the diagram is the gate between writing and running. Nothing with side effects happens until the plan passes the check. The dashed return arrow is the second feature. A plan is a forecast, and forecasts fail. The agent must treat a failed step as new information and plan again, rather than pushing on with a plan that no longer fits.
Plan-and-Solve prompting, described by Wang and colleagues in 2023, supports the first half of this design. It asks the model to devise a plan that splits the task into subtasks, then to carry the subtasks out. The paper shows this kind of explicit decomposition is a useful prompting pattern. A production planning agent builds on that idea by adding a review gate, limits, and a revision loop.
A worked example
Priya at Acme asks the agent: "Export last quarter's orders for the Berlin region as a CSV without customer emails, and send me the link." The agent has four tools: query_orders, redact_fields, write_file, and send_message.
The planner returns a plan with five steps. Step 1: query_orders for region Berlin, dates 1 July to 30 September. Step 2: redact_fields on the result, removing email and phone. Step 3: write_file to save the redacted rows as CSV. Step 4: send_message to Priya with the link. Step 5: confirm the file row count matches the query row count.
The checker reviews it. It notes that step 4 sends a message, which is an external side effect, and that the plan has no step that confirms the redaction worked before the file is written. It asks for a verification step after step 2. The planner adds "check that no column named email or phone remains". The checker approves the revised six-step plan.
Execution begins. Step 1 returns 4,210 rows. Step 2 removes two columns. The new verification step passes. Step 3 writes berlin_q3_orders.csv. Step 4 fails because the message service times out. The agent does not guess. It returns to planning with the failure, and the planner replaces step 4 with a retry plus a fallback of posting the link to the requester's task list. The retry succeeds. The final answer lists the file, the row count of 4,210, and the plan that was followed.
{
"goal": "Export Berlin Q3 orders without emails and send a link",
"steps": [
{"id": 1, "tool": "query_orders", "args": {"region": "Berlin", "from": "2026-07-01", "to": "2026-09-30"}, "side_effect": false},
{"id": 2, "tool": "redact_fields", "args": {"drop": ["email", "phone"]}, "needs": [1], "side_effect": false},
{"id": 3, "tool": "check_columns", "args": {"forbidden": ["email", "phone"]}, "needs": [2], "side_effect": false},
{"id": 4, "tool": "write_file", "args": {"format": "csv"}, "needs": [3], "side_effect": true},
{"id": 5, "tool": "send_message", "args": {"to": "priya"}, "needs": [4], "side_effect": true},
{"id": 6, "tool": "check_row_count", "needs": [1, 4], "side_effect": false}
]
}Building it
The sketch below separates the four jobs: planning, checking, running, and revising. It enforces a tool allow-list, a cap on plan length, a cap on revisions, and a per-step timeout. llm.generate(), run_tool(), and ask_person() are placeholders for your own code.
import json
# Placeholders: replace with your own model client and tool runner.
# llm.generate(prompt) -> str ; run_tool(name, args, timeout_s) -> dict ; ask_person(text) -> bool
ALLOWED_TOOLS = {'query_orders', 'redact_fields', 'check_columns', 'write_file', 'send_message'}
MAX_STEPS = 10 # a plan longer than this is probably confused
MAX_REVISIONS = 2 # stop endless replanning
STEP_TIMEOUT_S = 30 # no single step may hang the run
def write_plan(goal, facts):
prompt = f'Goal: {goal}\nKnown facts: {facts}\nReturn a JSON list of steps with tool, args, needs.'
return json.loads(llm.generate(prompt))
def check_plan(plan):
# Cheap rules first: they catch most problems without a model call.
if len(plan) > MAX_STEPS:
return False, 'plan too long'
for step in plan:
if step['tool'] not in ALLOWED_TOOLS:
return False, f"tool not allowed: {step['tool']}"
# A second model call reviews order and gaps; risky steps go to a person.
verdict = llm.generate(f'Review this plan for gaps and wrong order: {json.dumps(plan)}')
if 'problem' in verdict.lower():
return False, verdict
if any(s.get('side_effect') for s in plan):
return ask_person(f'Approve plan? {json.dumps(plan)}'), 'human review'
return True, 'ok'
def run_plan(plan):
results = {}
for step in plan:
try:
results[step['id']] = run_tool(step['tool'], step.get('args', {}), STEP_TIMEOUT_S)
except Exception as err:
return results, {'failed_step': step['id'], 'error': str(err)}
return results, None
def run_agent(goal):
facts = {}
for attempt in range(MAX_REVISIONS + 1):
plan = write_plan(goal, facts)
ok, note = check_plan(plan)
if not ok:
facts['plan_rejected'] = note # feed the reason back to the planner
continue
results, failure = run_plan(plan)
if failure is None:
return {'status': 'done', 'plan': plan, 'results': results}
facts['last_failure'] = failure # new information for the next plan
return {'status': 'gave_up', 'facts': facts}
The plan is data, not hidden reasoning. Because it is a JSON list, your code can validate it, log it, diff it against earlier plans, and show it to a person. That structure is the main practical benefit over an agent that merely thinks in text.
Design decisions
- Plan format: use structured data with step ids, tools, arguments, and dependencies. Free text cannot be validated by code. Default to JSON with a schema.
- Who checks the plan: use rules for hard limits such as allowed tools and plan length, a model for gaps and ordering, and a person for steps with side effects. Layering keeps cost down.
- Revision limit: allow one or two revisions. More than that usually means the goal is unclear, and a person should step in.
- Latency and cost: the planning call adds a delay before any work starts. Use a strong model for planning and a cheaper one to run simple steps if the work is heavy.
- Failure handling: save each step's result, so a revised plan can reuse finished work instead of repeating it. Make side-effect steps idempotent.
- Access control: enforce the tool allow-list in code, outside the model. A plan that names a forbidden tool should never reach the runner.
- Versioning: log the plan, the plan version, and the model version with each run, so you can explain and replay what happened.
Measuring it
- Task success rate: the share of test goals that end in a correct result, judged by a checklist or a script. Use a fixed set of goals so runs are comparable.
- Plan validity rate: the share of first plans that pass the check without revision. A low rate points at weak planner prompts.
- Revision rate: average revisions per run. Rising values suggest the world changes faster than plans can track.
- Plan fidelity: the share of runs where the executed steps match the approved plan. Deviations show hidden improvisation.
- Cost and time per task: total tokens and seconds, split into planning, checking, and running, so you can see where the overhead is.
When to use it, and when not to
| Situation | Use this type? | Why |
|---|---|---|
| A multi-stage task with clear dependencies, such as a data export or onboarding flow | Yes | Order matters, and a reviewed plan prevents out-of-order work. |
| Work with irreversible side effects such as sending, paying, or deleting | Yes | The plan can be approved by a person before anything happens. |
| A long job where discovering a missing permission late would be costly | Yes | Planning surfaces gaps before the first action. |
| A single lookup or a one-step action | No | Planning adds delay and cost with no benefit. A reactive agent is enough. |
| An open question where each answer decides the next move | No | The plan would be a guess. A ReAct agent adapts as it learns. |
| A fast-changing environment where facts shift mid-run | Maybe | Plans go stale quickly, so keep them short or replan often. |
Trade-offs
| Dimension | Effect | What to do about it |
|---|---|---|
| Quality | Better ordering and fewer surprises on structured tasks. A wrong plan can still be followed faithfully. | Add a plan check and a verification step after risky stages. |
| Latency | A delay before any action, because the plan and the check come first. | Keep plans short and run independent steps together where safe. |
| Cost | Extra model calls for planning, checking, and revision. | Use rules for simple checks and a smaller model for easy steps. |
| Complexity | More parts than a reactive agent: planner, checker, runner, revision logic. | Keep each part small and log the plan as data. |
| Failure modes | Stale plans, plans that look sound but miss a hidden dependency, and endless replanning. | Cap revisions, validate step results, and escalate to a person. |
Compared with related types
The reactive agent has no plan at all, so it is faster and cheaper but cannot handle dependent steps. The ReAct agent is the other end of the scale. It decides one step at a time, using each tool result to choose the next move. That flexibility suits uncertain tasks, but there is no moment where a person can approve the whole route in advance.
The plan-and-execute agent is the engineered descendant of this pattern. It splits the planner and executor into separate roles, often with different models. If your plans are long and most steps are routine, that split saves money. If you need a person to sign off on risky steps, see the human checkpoint pattern.
What this means for your role
Common mistakes
Further reading
- Types of AI agents: the hub page that compares every agent type.
- Plan-and-Solve prompting, Wang et al., 2023: asks the model to first devise a plan that splits the task into subtasks, then carry the subtasks out.
- Russell and Norvig, Artificial Intelligence: A Modern Approach: a book that sets out the classic agent taxonomy, including goal-based agents that look ahead.
- Human checkpoint: how to pause a run for approval.
- Guardrails and safety: controls to place around risky steps.
A planning agent trades speed for foresight. Use it where order, review, and avoiding costly side effects matter more than the first second of latency.