# What is Agent Loop? Also called execution loop, control loop. The agent loop is the repeating cycle at the center of every agent: assemble context, ask the model what to do, execute the chosen action, add the result to context, and repeat until a stopping condition is met. Stopping conditions include producing a final answer, hitting a step or budget limit, or requiring human approval. Each pass through the loop is a fresh model request. The runtime rebuilds the input from the system prompt, the relevant history, retrieved memory, and the tool definitions, sends it, and receives either an answer or an action. Nothing persists inside the model between passes, so every piece of continuity comes from what the runtime chooses to put back in. Termination is where naive implementations fail. Without limits an agent can retry a failing tool indefinitely, alternate between two actions, or continue refining an answer that was finished several steps ago. Production loops carry a maximum step count, a wall-clock timeout, a spend cap, and usually a loop detector that notices repeated identical calls, each of which ends the run safely. The other structural problem is growth. Every step appends to the history, so a long run steadily fills the context window with older material until the important instruction is crowded out or the request no longer fits. Strategies include summarizing completed phases, dropping raw tool output once its conclusion is recorded, and moving long-lived facts into external memory. The loop is what people mean when they call something agentic, and its shape is the ReAct pattern. Orchestration wraps around it to persist state and handle failures across steps. Autonomy level determines how many passes may happen before a person is consulted. Reading a loop's recorded passes in order gives the trajectory used to debug the run. ## Key points - Each pass rebuilds the model input; nothing persists inside the model. - Step counts, timeouts, and budgets prevent runaway loops. - History grows every pass and eventually crowds the context window. - Stops on final answer, limit reached, or approval required. ## In practice An agent is asked to find and fix a broken link on a page. Pass one: it reads the page and gets the HTML. Pass two: it checks three links and finds one returning an error. Pass three: it searches for the current address. Pass four: it writes the correction and reports done. Four passes, three tool calls, one stopping condition met. ## Related terms - [ReAct Pattern](/en/glossary/react-pattern) - [AI Agent](/en/glossary/ai-agent) - [Agent State](/en/glossary/agent-state) - [Agent Orchestration](/en/glossary/agent-orchestration) - [Tool Use](/en/glossary/tool-use) [Back to the AI Glossary](/en/glossary)