An agent loop is what turns a model into a worker. The model is given a goal, a set of tools, and a stopping condition. It proposes a step, the host executes a tool, the result goes back into the context, and the model decides what to do next. The loop ends when the task is done, a budget is exhausted, or the model asks for help.
The loop changes the economics and the risk. Every step resends the growing context, so cost grows faster than the number of steps. Every step is a chance to call the wrong tool with the wrong argument. A ten-step task is not ten independent requests; it is one trajectory with ten decisions.
Design the loop with explicit budgets: a maximum number of steps, a token ceiling, a timeout, and a list of actions that require confirmation. Log the trajectory, not just the final answer, and test it as a workflow rather than a single prompt. See test an agent workflow.