When does an agent loop stop?
It stops when the model returns a final answer instead of a tool request, when the program hits a limit on steps, time or cost, or when a person interrupts it. Good agent setups always have some limit.
The repeated cycle of decide, act with a tool, observe the result, and decide again that makes an AI an agent.
An agent loop is the repeating cycle that turns a language model into an agent. The program sends the model the goal and everything that has happened so far. The model replies either with a final answer or with a request to use a tool, such as reading a file, running a test or searching. The program runs that tool, adds the result to the conversation, and asks the model again. This continues until the model says it is finished, a step limit is hit, or a person stops it. The model itself does not run anything; the surrounding program does.
Most of what makes coding agents useful, and most of what makes them go wrong, happens inside this loop. Each turn adds tool output to the context, so long loops get slow, expensive and confused. Knowing the loop exists helps you give agents a way to check their own work, such as a test command, so each pass through the loop moves toward a verified result instead of a guess.
A coding agent asked to fix a failing test might loop like this: read the test file, run npm test, read the error, open the source file, edit one function, run npm test again, see it pass, and report back. That is roughly six turns of the loop. If the instructions file had not named the test command, the agent would spend extra turns guessing it.
An agent is not a different kind of model. It is usually the same chat model wrapped in a program that runs tools and feeds the results back. The loop, the tools and the instructions are what make it agentic.
All 28 terms are in the AI glossary. For models side by side, see frontier vs open-weight.
It stops when the model returns a final answer instead of a tool request, when the program hits a limit on steps, time or cost, or when a person interrupts it. Good agent setups always have some limit.
Every tool result is added to the context, so the context fills with old output. The model then has more to read, costs more per turn and can lose track of earlier details. Shorter tasks or subagents help.
No. The model only writes text that asks for a tool call. The agent program decides whether to run it, often asking a person for permission first, and then passes the result back.