Agent Loop
An agent loop is the control cycle that turns a model response into an ongoing, goal-directed process. Instead of answering once, the agent repeatedly decides, acts, receives feedback, and updates its understanding of the task.
The core cycle
A practical agent loop can be expressed as:
- Read the goal and current state.
- Reason about the next useful step.
- Choose an action or produce a final answer.
- Execute the action through a tool or system.
- Receive an observation describing the result.
- Update state.
- Continue, stop, or ask for help.
The loop may run once for a simple task or many times for a complex one. How AI Agents Work explains this execution cycle in the wider agent architecture.
A simple example
Imagine a research agent asked to identify three reliable sources about a technical topic. It first searches the web. The search results become observations. It then opens promising pages, rejects irrelevant material, records useful evidence, and searches again if important information is missing.
The agent finishes only when it has enough suitable sources or reaches a limit. Its answer is therefore the result of a trajectory, not one model generation.
The loop needs control
An agent loop should have explicit stopping conditions. Common conditions include:
- The goal has been satisfied.
- The agent needs user approval.
- A tool keeps failing.
- A time, cost, or step limit has been reached.
- The agent cannot make safe progress.
Without these controls, the agent may repeat actions, spend unnecessary resources, or continue after completing the task. Production systems often add retry limits, timeouts, approval gates, and deterministic checks around the model.
Agent loop versus workflow
A workflow follows a predefined sequence. An agent loop allows the next step to depend on the latest state and observation. The two can work together: deterministic code can own the main workflow while an agent loop handles bounded decisions inside it.
The important feature is feedback. An agent becomes adaptive when each result can change what it does next.
Learn More
How AI Agents WorkContinue with the full AIRundown guide →