# Agent loop

The finite runtime cycle in which an agent interprets state, selects an action, observes the result, updates state, and decides what happens next.

technical-term · Harness & runtime · maturing · Reviewed 2026-08-09

## Definition

The agent loop is the control cycle that turns a model call into goal-directed behavior: construct context, reason or plan, choose a tool or response, validate the proposed action, execute inside bounds, observe the effect, update working state, verify progress, then finish, retry, correct, hold, or escalate.

The loop pattern is well established; robust long-running recovery and control remain active engineering areas.

## Why it matters

Each loop turn changes the next decision context, so small errors can compound.

Finite verbs and budgets make loop behavior testable: bind, block, correct, hold, release, escalate, stop.

## System anatomy

- **Orient:** Construct the current state and bounded context.
- **Decide:** Select a next action or termination state.
- **Act:** Validate and execute through a governed tool.
- **Observe:** Capture the result and environmental change.
- **Disposition:** Continue, correct, finish, hold, or escalate.



## Important distinctions

- **Infinite retry:** A production loop has budgets, state changes, and an explicit terminal condition.
- **Chain of thought:** The loop is an observable software control structure; private model reasoning is not the system boundary.



## Implementation signals

- Make each transition and side effect observable
- Require new evidence before retrying
- Test completion and failure paths as first-class behavior

## Failure modes

- Retrying the same prompt without changing state
- Tool side effects occurring before policy and argument checks
- No durable checkpoint before context loss



## Related knowledge

- [AI agent](https://aisdlc.ai/agentic-engineering/ai-agent) — A goal-directed software system in which a model dynamically chooses steps and tools, observes results, updates working state, and continues until an exit condition or human handoff.
- [Goal and exit condition](https://aisdlc.ai/agentic-engineering/goal-exit-condition) — A testable target paired with the finite states that determine when an agent completes, blocks, escalates, or stops.
- [Harness engineering](https://aisdlc.ai/agentic-engineering/harness-engineering) — Engineering the agent loop, task decomposition, tools, permissions, session state, checks, retries, feedback, checkpoints, and stop conditions that surround a model.
- [Durable execution](https://aisdlc.ai/agentic-engineering/durable-execution) — Execution that persists state and can resume safely across process, model, context, worker, or environment interruptions.
- [Loop engineering](https://aisdlc.ai/agentic-engineering/loop-engineering) — The practice of improving the complete perceive–decide–act–observe cycle around a model rather than optimizing prompts in isolation.

## Sources and further study

- [Anthropic — Trustworthy agents in practice](https://www.anthropic.com/research/trustworthy-agents) — Describes a self-directed plan–act–observe–adjust loop and the engineering layers needed to make longer-horizon agents more trustworthy. **Use:** Primary definition. **Limitation:** This first-party synthesis describes design directions and failure surfaces; it is not a certification scheme or evidence that every described control is sufficient.
- [arXiv / ICLR — ReAct: Synergizing Reasoning and Acting in Language Models](https://arxiv.org/abs/2210.03629) — Studies interleaved reasoning traces and environment actions, a foundational pattern for model-driven agent loops. **Use:** Primary definition. **Limitation:** Reported benchmark gains do not establish reliability for open-ended production environments or permission for consequential action.
- [OpenAI — A practical guide to building agents](https://openai.com/business/guides-and-resources/a-practical-guide-to-building-ai-agents/) — Defines a practical agent around a model, tools, instructions, and a run loop that continues until an exit condition is reached. **Use:** Primary definition. **Limitation:** The guide is first-party product guidance and a simplified starting architecture, not a complete regulated-enterprise control model.

---

This library synthesizes cited research, standards, official documentation, and clearly attributed practitioner perspectives. Maturity describes the state of a concept—not vendor endorsement, production readiness, or permission to deploy. Benchmarks and demonstrations do not replace use-case evaluation, governed controls, independent verification, or named human release authority.
