Guide

The Agent Loop, Explained: Plan, Act, Observe, Evaluate

An AI agent isn't one clever answer. It's a loop: plan, act, observe, evaluate. Watch the agent loop run as an interactive machine you can step through.

Contents

Orange robot arms stationed along an automated automotive assembly line, each doing one step as parts move from station to station

Image: Simon Kadula on Unsplash.

Ask a chatbot to fix a failing test and you get a confident guess. Maybe it's right. You won't know until you run it.

Ask an agent and something different happens. It runs the tests, reads what broke, changes course and runs them again, until they pass. That repeat is the whole trick, and it has a name: the agent loop.

Anthropic, which builds agents for a living, puts it in one line: agents "are typically just LLMs using tools based on environmental feedback in a loop" (Anthropic). This piece shows you that loop running. For the full anatomy of the model, the tools and the harness, see how AI agents work.

What is the agent loop?

The agent loop (also called the agentic loop) is the cycle an AI agent repeats to finish a task: plan the next step, act with a real tool, observe what actually happened, and evaluate the result against the goal. Not done? Round again, with a better plan.

  1. Plan. Read the goal and everything learned so far. Decide the single next step.
  2. Act. Pick the right tool for that step, such as a shell, a web search or a file edit, and do real work.
  3. Observe. Measure the result. Not what the model hoped would happen: what the test runner, the page or the API actually returned.
  4. Evaluate. Compare it to the definition of done. Pass, and the task ships. Fall short, and the loop runs again.

Why a loop beats one clever answer

Reality is the referee. Language models are fluent, and fluent is not the same as correct. Anthropic calls it "crucial for the agents to gain 'ground truth' from the environment at each step (such as tool call results or code execution) to assess its progress" (Anthropic). The observe step swaps the model's confidence for evidence: an exit code, a test count, a page that loaded.

Every miss makes the next plan smarter. A failure isn't the end. It's information. "4 of 6 tests pass" tells the next iteration exactly where to look.

"Done" is a check, not a feeling. The evaluate step is what lets an agent stop, and what stops it declaring victory early. A good loop has a goal you can verify. We go deeper on that in AI agent evaluation and the gold standard system.

A laptop showing code in a dark room, where an agent loop runs tests, edits files and runs the tests again

Image: Mohammad Rahmani on Unsplash.

Watch the agent loop run

We built the loop as a real machine: a rotary indexing table that carries one task through four stations, a quarter turn at a time. Press play for the narrated tour, or click the machine to pause and use the arrow keys to step through it. One task, three trips round: 4/6, then 5/6, then 6/6. Then it ships.

Plan punches the plan into the part. Act fits a tool and adds real work. Observe gauges how many tests pass. Evaluate opens the gate to Done, or sends the task round again.

Read the narration

This is the agent loop, built as a machine. One task rides a rotary table through four stations, a quarter turn at a time.

First, Plan. The agent reads the goal, and punches its plan into the part: run the tests, and see what's broken. Act. It picks a tool from the rack. The shell runs the test suite, and real work lands on the part. Observe. A gauge measures what actually happened, not what the agent hoped. Four of six tests pass. Evaluate. Four is short of six, so the gate stays shut, and the task rides around again.

Back at Plan, it revises. The failures point at an API it doesn't know, so the next step is research. A different tool this time: the web. It pulls the docs. Five of six. Closer. Still short. Around again.

Plan three: patch the parser. The file tool makes the edit. Six of six. Evaluate passes. The gate opens, and the ram pushes the finished task out to Done.

That's the whole idea. An agent isn't one clever answer. It's a loop: plan, act, observe, evaluate, until the work is verifiably done.

How this maps to AGNT

Disclosure: AGNT is our product. In AGNT, an agent runs this loop with an explicit tool list and its own model, and open-ended outcomes run as goals that plan, execute, evaluate and replan. Every run writes a receipt that records each step, error and retry, so you can see exactly why the loop went round again, and why it stopped. It runs locally, and the download is free.

FAQ

What is an agent loop?

The cycle an AI agent repeats to finish a task: plan the next step, act with a tool, observe the real result and evaluate it against the goal. If the goal isn't met, it goes round again with a better plan.

How is an AI agent different from a chatbot?

A chatbot returns one answer per prompt. An agent takes actions through tools, checks what actually happened and keeps going until a defined goal is verifiably met.

When does an agent stop looping?

When evaluation confirms the goal is met, such as every test passing, or when it hits a limit you set, such as a step budget or a required human approval.

Sources

Agent LoopAI AgentsAgentic WorkflowsInteractive