# The agent loop

URL: https://justuju.org/concept/agent-loop/
Layer 8 · Agents

Plan, act with a tool, observe the result, and repeat until the goal is met.

## D1 · Story

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.
1. Look: what is the room like?
2. Choose: one next step
3. Do it: with a computer tool
4. Done?: is it tidy yet?
Like: A robot tidying a room, one item at a time.

## D2 · Picture

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.
1. Goal: from the user
2. Think: choose next step
3. Act: call a tool
4. Observe: read the result
5. 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.

## D5 · Frontier

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: https://arxiv.org/abs/2210.03629
- Building effective agents (Anthropic): https://www.anthropic.com/research/building-effective-agents
- Measuring AI Ability to Complete Long Software Tasks (METR): https://arxiv.org/abs/2503.14499
- τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains: https://arxiv.org/abs/2406.12045
- Recent Frontier Models Are Reward Hacking (METR): https://metr.org/blog/2025-06-05-recent-reward-hacking/
- WASP: Benchmarking Web Agent Security Against Prompt Injection Attacks: https://arxiv.org/abs/2504.18575


---
Justuju · https://justuju.org/ · Content CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote with a link to the page.
