The agent loop
Plan, act with a tool, observe the result, and repeat until the goal is met.
Read first: Tool use & protocols (MCP).
D1 · StoryFor young children and total beginners
Think of a robot tidying a room: look around, pick one thing up, check where it goes, then look again. It keeps going until the room is tidy.
An AI agent works the same way, using computer tools instead of hands.
Look, choose, do, check
- Look: what is the room like?
- Choose: one next step
- Do it: with a computer tool
- Done?: is it tidy yet?
Like: A robot tidying a room, one item at a time.
D2 · PictureFor curious beginners
The agent receives a goal. The model reasons about the next step and requests a tool call.
The harness runs the tool, with permission checks, and feeds the result back into the context.
The loop repeats until the model decides the task is done, a limit is reached, or a person steps in.
The agent loop
- Goal: from the user
- Think: choose next step
- Act: call a tool
- Observe: read the result
- Done?: stop or continue
Like: A robot tidying a room.
Where it breaks: A tidying robot can see the whole room. An agent only sees what's in its context, so long tasks need summaries and memory, and details can get lost.
D3 · PlayFor motivated learners
An agent task is a chain of steps: read a file, call a tool, edit, run a test. The whole task only succeeds if every step does.
If each step succeeds with chance p, and steps fail independently, a task of n steps finishes with chance p to the power n. Small per-step errors compound fast.
A check and retry step helps: a test or a second look catches some failures, and the agent gets one more try. Turn it on and watch the curve lift.
Try the interactive version in the map.
Things to try
- Leave each step at 95% and set 20 steps. How often does the whole task finish?
- Set 50 steps. How good must each step be for the task to finish at least half the time?
- Turn on check and retry at 80%. How much does it lift 20 steps? Now drop the catch rate to 0%.
D5 · FrontierFor experts
The loop of think, act and observe looks the same for a two-step task and a two-day one, but reliability does not stretch with it.
Long tasks. The length of task frontier agents finish half the time has doubled about every seven months since 2019, and success still falls as tasks get longer (METR, 2025).
Consistency. An agent that solves a task once may fail it on the next try; in one benchmark, leading agents solved under a quarter of one domain's tasks on all eight attempts (τ-bench, 2024).
Gaming the goal. Recent models sometimes changed timers, tests or scoring code instead of doing the task, and telling them not to cheat had little effect (METR, 2025).
Untrusted observations. Every tool result can carry instructions. Injected web content partly hijacked web agents in up to 86% of cases, though they often failed to finish the attacker's goal (WASP, 2025).
Examples as of 2026-10-30
- The ReAct pattern (reason, act, observe)
- OpenAI Agents SDK
- Claude Agent SDK
- LangGraph
Sources
- ReAct: Synergizing Reasoning and Acting in Language Models (2022)
- Building effective agents (Anthropic) (2024-12-19)
- Measuring AI Ability to Complete Long Software Tasks (METR) (2025-03-18)
- τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains (2024)
- Recent Frontier Models Are Reward Hacking (METR) (2025-06-05)
- WASP: Benchmarking Web Agent Security Against Prompt Injection Attacks (2025-04-22)
How it connects
- Retrieval-augmented generation (RAG) grounds The agent loop.
- Tool use & protocols (MCP) gives actions to The agent loop.
- The agent loop runs inside each Multi-agent systems.
- The agent loop powers Copilots.
- Agent harnesses runs and guards The agent loop.
More in Layer 8 · Agents
- Agent harnesses
The program wrapped around a model that turns it into an agent: it runs tools, asks permission, manages context and keeps memory. - Coding agents
Agents that work inside a code repository: read files, make edits, run commands and tests, and iterate until the checks pass. - Computer & browser use
Agents that operate a screen like a person: look at a screenshot, then click, type and scroll. - Multi-agent systems
Several agents with different roles or contexts work together on one task.