LLM ReferenceLLM Reference
AI Glossary
agentsintermediate

Agentic loop

Definition

The agentic loop is the repeating cycle at the heart of every autonomous AI system: model → tool call → result → model → tool call → result → … until the model produces a final answer or the harness stops it. On each iteration, the harness sends the model its current context, the model responds either with a tool call or a final message, the harness executes any tool call and feeds the result back into context, and the loop continues.

This loop is what distinguishes agentic systems from simple chat. A chat completion is one turn — prompt in, response out. An agentic loop lets the model gather evidence, act, observe the effect, and revise its plan, turn after turn. It is how an AI actually does things — edits files, runs tests, searches, deploys — rather than just describing what it would do.

Key design questions around the loop include: how many iterations to allow before escalating, how to compact context as history grows, how to detect when the model is stuck in a tool-call loop, how to handle errors from tool results, and when to hand control back to a human. Most harnesses expose configuration for all of these.

The loop is executed by the harness; the steps taken within the loop depend on the agent's role, mission, and scope; and the quality of each step depends on the model and the context it receives.