Agent loop
An agent loop is the repeating cycle of an AI agent — observe state, decide on an action (usually a tool call), execute, observe the result, and repeat — until a goal is reached or a stop condition fires.
Every AI agent in 2026 runs some variant of an agent loop. The simplest is pure ReAct (thought → action → observation, repeat). Production loops add planner-executor splits, budget caps, no-progress detectors, retry handlers, and circuit breakers. The hardest engineering problem is reliability across long loops: by step 15 most loops drift off-goal without active context distillation, summarisation, and goal re-injection. Best practice in 2026 is to keep loops as short as possible — fewer steps with stronger per-step quality beats long loops with weak steps.
When to use agent loop
- Any tool-using agent.
- Multi-step workflows where each step depends on the previous result.
Common mistakes
- Letting the loop run unbounded — set step + token + wall-clock caps.
- Skipping a planner — pure ReAct drifts on horizons past ~7 steps.
FAQ
What is agent loop?
An agent loop is the repeating cycle of an AI agent — observe state, decide on an action (usually a tool call), execute, observe the result, and repeat — until a goal is reached or a stop condition fires.
When should I use agent loop?
Any tool-using agent. Multi-step workflows where each step depends on the previous result.
What are the most common mistakes with agent loop?
Letting the loop run unbounded — set step + token + wall-clock caps. Skipping a planner — pure ReAct drifts on horizons past ~7 steps.
Related terms
- AI agent — An AI agent is a system where a language model autonomously plans and executes a sequence of tool calls to accomplish a goal.
- ReAct pattern — ReAct interleaves Reasoning + Acting in an agent loop — the model writes a thought, then decides to call a tool, then observes the result, then thinks again.
- Context distillation — Context distillation summarises an agent's growing conversation history into a compact representation, so each step's input stays small while preserving the relevant signal.
- Guardrails — Guardrails are deterministic checks layered around a language model to prevent unsafe, off-topic, or non-compliant outputs from reaching the user.
Last updated: 2026-06-01. Raw markdown: https://promtable.com/glossary/agent-loop.md.