← All news

News / Learn / AI agents

How do agents plan multi-step tasks?

You'll be able to explain how an agent breaks a big goal into steps and adjusts the plan as it works.

An agent often faces a goal too big to solve in one reply. Planning means the model splits that goal into smaller steps, picks an order, and decides which step to take next. After each step, it checks what happened and updates the plan.

Most useful agent work spans many steps, such as reading files, calling an API, checking results, and fixing errors. A weak plan wastes tokens, loops forever, or stops early. If you understand how planning works, you can design tasks that are easier for the model to finish and easier for you to debug.

The simplest planning style is implicit. The model reads the goal and picks the next action, one at a time, with no written plan. This works for short tasks. Many agent loops use it because it is cheap and flexible.

Explicit planning writes the plan down first. The model produces a numbered list of steps, often as structured output, and then the loop works through the list. You can show the plan to a user, check it before any action runs, or store it so the agent can refer back to it. The tradeoff is that a plan can go stale when a step returns surprising results.

Replanning closes that gap. After each step, the model sees the tool result and decides whether to continue, change a step, add one, or stop. Good agents treat the plan as a draft, not a contract.

Decomposition is the skill behind all of this. Steps should be small, concrete, and checkable. A step like "find the three slowest queries and report their names" is easier to verify than "improve performance." Clear step boundaries also make failures easier to isolate.

Finally, stopping rules matter. A plan needs a definition of done and a limit on steps or retries. Without them, an agent can keep planning and acting long after the task is finished or impossible.

A simple plan-then-execute loop. The planner returns a list of steps, and the executor runs each one and records the result.

def run_task(goal, llm, tools, max_steps=10):
    plan = llm.plan(goal)  # returns a list of step strings
    results = []
    for i, step in enumerate(plan[:max_steps]):
        outcome = llm.execute(step, tools, history=results)
        results.append({"step": step, "result": outcome})
        if outcome.get("done"):
            break
        if outcome.get("needs_replan"):
            plan = plan[:i + 1] + llm.replan(goal, results)
    return results

A short sketch to show the idea. Check the official docs of the tool you use.

  • Planning once and never revisiting it Let the agent review the plan after each result. Tool outputs often change what the right next step is.
  • Steps that are too large to check Split steps until each one has a clear output you can verify, such as a file written or a value returned.
  • No step or retry limit Cap the number of steps and retries. Stop and report to the user when the cap is reached.
  • Trusting the plan over the evidence If a tool result contradicts the plan, the plan should change. Build the loop so results can override the plan.

Read about the agent loop, tool calling, and evals. Evals help you measure whether a planning change actually improved task completion.

Does an agent always need a written plan?

No. Short tasks often work fine with the model choosing one next action at a time. Written plans help most when tasks are long, need user approval, or must be audited.

What is the difference between planning and reasoning?

Reasoning is thinking through a single problem. Planning decides the order of multiple actions over time. An agent can use reasoning inside each planning step.

Why does my agent keep repeating the same step?

The loop may not record past results, or the stop condition is unclear. Pass prior results back into each step and define what done looks like.

Should the plan be shown to the user?

Often yes, for longer or risky tasks. Showing the plan lets people catch a wrong direction before the agent acts.

Written with AI by CapyLaunch. Spotted a mistake? Email hello@capylaunch.com.