Agent loop
An agent loop is the orchestration pattern where an LLM iteratively reasons, calls tools, observes results, and continues — until a terminal condition is met (task complete, max iterations reached, error). The loop is the foundation of any non-trivial AI agent: the LLM produces actions, the host executes them, and the result feeds back as context for the next iteration.
Agent loops vary in sophistication. The simplest is ReAct (Reason + Act): the model produces a thought, an action, and (after execution) observes the result before the next thought. More sophisticated patterns add planning (the model produces a full plan up-front), reflection (the model critiques its own progress), and hierarchical orchestration (a high-level agent delegates to specialist sub-agents). The engineering concerns are universal: max-iteration caps to prevent runaway, error handling on tool failures, observability into the trace, and cost controls. Production agent loops typically run 5-50 iterations per task; chains beyond that signal a problem in either the task or the agent design.
Related terms
- Autonomous agent
An autonomous agent is an AI system that pursues a goal over multiple steps with minimal human intervention — deciding what actions to take, executing them via tools, observing results, and iterating until the goal is achieved or judged unreachable.
- Tool use (LLM agent)
Tool use is the LLM-agent pattern in which the model has access to a defined set of tools — read file, search web, run code, query API — and decides which to invoke and with what arguments based on the user's request and the current state.
- Multi-agent system
A multi-agent system uses multiple LLM-driven agents working together — typically with role specialisation (planner, executor, critic) or domain specialisation (researcher, coder, writer).