Skip to content

How an agent works: the plan, act and check loop

Last checked 11 November 2026

An agent works in a loop. It reads the task, decides on a step, uses a tool to take it, looks at what came back, and decides again. Anthropic's description is that agents are typically just models using tools, guided by feedback from their surroundings, in a loop1.

OpenAI's agent tooling uses the same name. In its Agents SDK, a component called the runner handles the agent loop and handoffs2.

The stages

Anthropic describes the order of events this way1. An agent starts with a command from the user, or a discussion with them. Once the task is clear, it plans and works on its own. It may come back to the person for more information or a judgement call.

Here are the stages as a list, in plain words:

  • Start. The person states the goal.
  • Plan. The model works out a first step.
  • Act. The model asks for a tool to be used. A search, a file read, a calendar lookup.
  • Check. The result comes back and goes to the model.
  • Repeat or stop. The model plans again, or gives its final answer.
The agent loopRead the goal and what's knownPlan the next stepAct: call a toolCheck the resultFinish, or go round again
The loop repeats until the task is done or a limit stops it.

Where the checking comes from

Checking isn't the model's opinion of itself. Anthropic says the agent should get real information from its surroundings at each step, such as tool call results or code execution, to judge how it's going1. OpenAI's tool-calling guide shows the same shape. The application sends a request, gets back a tool call, runs it, and sends the output to the model. The model then returns a final answer, or more tool calls3. So the loop can run as many rounds as the task needs.

Where it stops

A loop needs ways to end. Anthropic lists several. Agents can pause for human feedback at checkpoints or when they hit a blocker. The task often ends when the work is done. It's also common to add stopping conditions, such as a maximum number of rounds, to keep control1.

If you're setting up or reviewing an agent, ask what its stopping rules are. A loop with no limit and no checkpoint is the case the makers' warnings are written for.

What the loop costs

Every round adds to what the model has to read. The context window is all the text a language model can reference when generating a response, including the response itself4. Anthropic notes that as the amount of text grows, accuracy and recall degrade4. More rounds therefore mean more text to carry.

Anthropic also says the autonomous nature of agents means higher costs and the potential for compounding errors1. A small slip early on can carry into every later step. Why agents go wrong covers the kinds of slip the makers name.

The tool calling page explains the "act" step in detail.

Where the facts come from

  1. Building effective agents, Anthropic
  2. Agents, OpenAI
  3. Function calling, OpenAI
  4. Context windows, Anthropic