Agent Loop

Agent Loop

Also called: 智能体循环 · Agentic loop · Run loop

The repeating cycle observe state → model decides → execute tool → feed result back; the underlying structure of almost every agent framework.

Observe stateModel decidesExecute toolFeed result back
Schematic (simplified)

What happens in one iteration

  1. The current context (goal, history, last observation) is passed to the model.
  2. The model emits a decision: call a tool with arguments, or declare the task complete.
  3. The runtime executes that tool and gets a result (file contents, command output, an error).
  4. The result is appended as a new "observation" and the next iteration begins.

The loop ends when the model declares completion, a step/spend limit is reached, or an error stop-condition fires.

Why it is central

The loop turns a single generation into a process that can try, fail, and correct: real feedback at each step revises the model's next decision. Much of what distinguishes agent frameworks is how this loop handles memory, errors, termination, and human intervention points.

Common misconceptions

  • The loop is not internal model behaviour — runtime code drives it, and the model is invoked once per iteration.
  • Without an explicit termination condition, the loop spins in place or exhausts its budget.

Related terms

Sources

  1. Yao et al. — ReAct: Synergizing Reasoning and Acting in Language Models (arXiv:2210.03629)
  2. Anthropic — Building effective agents (2024)

Compiled 2026-08-29 · This glossary is compiled from public papers, official specifications, and common industry definitions, and is updated as the field evolves. Corrections welcome.