Skip to content

loop, not the model

“Loop, not the model” is the idea that an AI agent is defined by the control loop around a language model: ask the model what to do next, execute a tool or action, feed the result back as context, and repeat until a stopping rule ends the run.

The reason this distinction matters is that a single model call is just a prediction over text, not an autonomous worker. It cannot see whether a command succeeded, whether an API returned bad data, or whether its last action changed the world unless the surrounding system tells it. Agent behaviour appears when software keeps re-invoking the model with updated state and gives it controlled ways to act.

Concretely, the loop starts with a goal, instructions, available tools, and current context. The model emits either a final answer or a structured request to call a tool. The runtime validates that request, checks permissions, executes the tool, captures the output or error, appends that observation to the context, and calls the model again. The next step is therefore based on both the original goal and what just happened.

This loop creates useful autonomy, but it also creates new failure modes. The model can choose the wrong tool, supply malformed arguments, misunderstand a tool result, repeat an ineffective action, forget the goal, or stop too early. The runtime can also fail by hiding important state, retrying badly, allowing unsafe actions, or missing a termination condition. Many agent bugs are orchestration bugs, not proof that the underlying model is incapable.

Engineers meet this idea when building tool-using chat systems, coding agents, browser agents, workflow automations, and MCP-style integrations. The practical design work is deciding tool schemas, context management, permission boundaries, retry policy, logging, and stop conditions. A good debugging habit is to draw the loop and mark where the run went wrong: instruction, plan, tool call, result interpretation, state update, or termination.

Common questions

Is an agent just a language model with better prompts?
No. Better prompts can improve behaviour, but an agent also needs runtime control flow. The system must expose tools, validate actions, execute them, capture results, update context, and decide whether to continue. Without that loop, the model can suggest actions but cannot observe their effects or adapt over multiple steps.
Where do agent loops usually fail?
Common failures occur at the boundaries between steps. The model may pick an unsuitable tool, pass arguments that do not match the schema, or misread the returned data. The system may omit needed state, retry in a way that reinforces the mistake, allow an unsafe action, or fail to stop a useless repetition.
How should I debug an agent loop?
Log the loop as a sequence of decisions and observations, not as a single chat transcript. For each iteration, inspect the prompt context, the model’s chosen action, the tool input, the raw result, and the next model call. Then identify whether the failure came from instruction, state, tool design, validation, interpretation, or stopping logic.