esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

How Do Agents Plan?

How an AI agent writes a list of steps, checks each result and rewrites the list when something breaks, with the limits to name, explained for your AI interview.

In short

An agent plans by writing a list of steps, doing one, reading the result and changing the list when something goes wrong. Some agents write the whole plan first, and others plan step by step. The plan is only text, so code has to cap and check it.

10 min readIntermediateCommon · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

An agent plans by writing a list of steps for the task. Then it does one step, reads what came back, and changes the list if something went wrong. Some agents write the whole plan first, and others plan as they go. The catch is that a plan is just generated text, so it can miss a step or break. That is why I cap the steps in code and send risky steps to a person.

What does it mean for an agent to plan, in plain words?

A plan is a list of steps the agent means to take, written as text before or during the job. An AI agent is an AI app that uses tools, such as reading files or running tests, to finish a task. Planning is how it works out the next steps and what to do when one fails.

Picture a new claims handler at an insurance firm. She writes a checklist for each claim (check the policy, check for fraud flags, draft the letter), ticks items off, and adds a step when the policy number is missing. An AI claims agent does the same. The one change is that the model writes the list, so your code has to check it.

Key words

Plan
A list of steps the agent intends to take, kept as text.
Replan
Rewriting the rest of the list after a step gives a surprising result.
Stopping condition
A rule in code that ends the loop, such as a maximum number of steps.
Sub-agent
A smaller agent given one subtask by a lead agent.

Should an agent plan first, or plan as it goes?

Real agents often mix both styles. Plan first suits fixed steps, like a set onboarding process. Plan as you go suits work where each result changes the next step, like fixing a failing build.

  • Plan first

    Write the list, then run it

    Set at the start and run in order. Easy to review, but stiff when a step surprises it.

  • Plan as you go

    Decide one step at a time

    The model picks the next move from the last result. It adapts well, but costs more, because the AI is asked again for each move, and it can wander off course.

Two ways to plan the same job

Upgrade 40 services

one library, many repos, some break

Plan first

Write every step

the whole list before any run

Run the list in order

no change on the way

Plan as you go

Pick one step

the model chooses the next move

Act and read the result

the real output, not a guess

Easy to review, but stiff

breaks when a step surprises it

Adapts to surprises

costs more: one AI call per step

  1. 1Write the full list first, then run it.
  2. 2Decide one step at a time, from each result.
  3. 3Once the list is set, surprises go unhandled.
  4. 4Each result can change the next step.
Two ways to plan the same job. Plan first writes every step up front. Plan as you go picks each step after the last result, which adapts but costs more.

ReAct, a 2022 paper, mixes reasoning and acting, so each result updates the plan. Its paper says reasoning traces "help the model induce, track, and update action plans as well as handle exceptions".

Plan-and-Solve, a 2023 prompting method, was built to address missing-step errors. Its paper says the method starts by "devising a plan to divide the entire task into smaller subtasks". Tree of Thoughts, also from 2023, goes further and considers "multiple different reasoning paths".

How does an agent change its plan when a step fails?

A plan only helps if the agent reads what each step really returned. Anthropic says agents need real feedback at each step, such as tool results or code execution.

Here is a made-up case from CI, the server that runs the tests on every change.

  1. 1

    The plan is written

    A coding agent in CI is asked to move 40 services to version 3 of a payments library. Its plan: update the library, run the tests, then open one pull request per service (a proposed code change that a person reviews before it merges).

  2. 2

    The tests fail in six services

    Version 3 renamed a retry option, so six services break. The agent reads the real test output and does not push on.

  3. 3

    The plan changes

    The agent rewrites the rest of its list: fix the renamed option in the shared wrapper, then rerun the tests in those six services.

  4. 4

    A person approves the last step

    Opening pull requests hands the work to people for review, so the plan marks that step for a person. Code also stops the run after eight steps, whatever the model writes.

The loop during a job

Model writes the plan

the next step, or a fix

One step

Run the step

a tool, a command or a test

Check the result

did it do what the plan needed?

Finished

every step passed

  1. 1The model hands over the next step.
  2. 2The output of that step is read.
  3. 3When every step has passed, the job ends.
  4. 4A failed check, or steps still left, goes back to the model.
The loop during a job. The model writes a step, the step runs, and the result is checked. A failed check sends the plan back for a fix.

Anthropic notes that agents commonly include stopping conditions, such as a maximum number of iterations. The code below shows the same idea in plain Python.

No real model is used, so the tests are pretend. The marked lines are the controls that matter.

Python
# A simplified upgrade agent. No real model: the plan is a list we wrote, and the tests are pretend.
MAX_STEPS = 8  # code stops the loop, whatever the model writes
RISKY = "open pull requests"
plan = ["update library", "run tests", RISKY]
fixed = False
steps_taken = 0

def run(step):
    # Pretend the tests fail until the agent adds a fix for the renamed option.
    if step == "run tests" and not fixed:
        return "FAILED: renamed retry option"
    return "ok"

while plan and steps_taken < MAX_STEPS:
    step = plan.pop(0)
    steps_taken += 1
    if step == RISKY:
        print("WAITING: a person must approve:", step)
        break
    result = run(step)
    print(step, "->", result)
    if result != "ok":
        fixed = True  # replan: add a fix, then run the tests again
        plan = ["fix renamed option", "run tests"] + plan
print("steps used:", steps_taken)

Output

update library -> ok
run tests -> FAILED: renamed retry option
fix renamed option -> ok
run tests -> ok
WAITING: a person must approve: open pull requests
steps used: 5

What can go wrong with an agent's plan?

A plan is generated text. The model can skip a step, pick a tool that does not exist, or stop early and say it has finished. Errors also compound: one wrong step leaves every later step planned from a false picture.

  • “The autonomous nature of agents means higher costs, and the potential for compounding errors.”

    Anthropic

  • “LLM agents are not yet great at coordinating and delegating to other agents in real time.”

    Anthropic, June 2025

  • “Prioritize transparency by explicitly showing the agent's planning steps.”

    Anthropic

So add three controls. Show the plan to the user so they can see it. Cap the steps in code. Send any risky step, like a payment or a sent email, to a person first.

Tip

In the interview, say the model proposes the plan and the code decides what runs. A plan is a suggestion, and the code is the boss.

What does the interviewer want to hear?

A strong answer covers

  • A plan is a list of steps the model writes, kept as text.
  • Two styles: plan first, or plan as you go, and when each fits.
  • Replanning: the agent reads each result and rewrites the rest.
  • Splitting big work into subtasks, with sub-agents when needed.
  • Limits: generated text, compounding errors, no guaranteed plan.
  • Controls in code: a step cap, a visible plan, approval for risky steps.

Common traps

  • Trap"The model plans, so it will always finish the job."

    BetterA plan is a guess that can be wrong. Code caps the steps and checks each result.

  • Trap"Chain of thought is the same thing as planning."

    BetterChain of thought is reasoning on the page. A plan is steps the agent acts on, then revises.

  • Trap"A longer prompt with the steps is enough."

    BetterA written plan helps, but only code can enforce the stops and the approvals.

Can you spot the planning problem?

Spot the risk

An agent wrote this plan for a bank's card-dispute bot. Which step should not run without a person?

Quick check

An agent's plan keeps looping on a missing document, with no end in sight. What is the best fix?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q158Workflow vs agent?10 min
  2. Q160What is the agent loop?12 min
  3. Q161What is ReAct for agents?12 min
  4. Q163Short-term vs long-term agent memory?12 min
  5. Q169When is a multi-agent system worth it?11 min
  6. Q173How do you stop endless agent loops?11 min

Learn it in depth

Last updated on 26 November 2026

Building an agent that has to plan real work?

I design and build AI agents, including the UI and the system behind them. Book a short call and tell me what the agent needs to do, and which steps a person must still approve.