An agent loop (also called a control loop or agentic loop) is the recurring cycle that lets an AI agent pursue goals across multiple steps:
- Perceive — Receive input (user message, tool result, environment state)
- Reason — Decide what to do next given the goal and current context
- Act — Execute a tool call, send a message, or update state
- Observe — Read the outcome of the action
- Repeat — Reassess whether the goal is met or another step is needed
This loop is what separates an agent from a chatbot. A chatbot completes one turn. An agent runs the loop until the task is done, an error requires escalation, or a safety limit is hit.
Common loop patterns
- ReAct (Reason + Act) — The model alternates between reasoning traces and tool calls. Widely used and easy to debug.
- Plan-and-execute — The model first generates a full plan, then executes steps sequentially. Better for long, structured tasks.
- Reflection — After acting, the model critiques its own output and may retry. Useful for quality-sensitive work.
Loop safety
Production agents need guardrails on the loop itself: maximum iteration counts, timeout limits, cost caps, and human-in-the-loop checkpoints for high-stakes actions. Without these, a confused agent can loop indefinitely.
Related reading
Loop Engineering covers how to design loops that are reliable in production, not just in demos.