Agent loop
Definition
The repeating cycle of model call, tool call, observation and next decision that drives an agent until the task is done or a limit is hit.
In more detail
Each turn of the loop sends the conversation so far to the model. If the model asks for a tool, the application runs it, appends the result and calls the model again. The loop ends when the model replies without a tool call, or when a limit on steps, time or cost is reached.
Because every tool result is added to the context, long loops fill the context window. Agent harnesses manage this with summarisation, clearing old results or handing work to subagents.
Related terms
Agent
A system where a model decides which actions or tools to use, in a loop, until a goal or stop condition is met, rather than following fixed steps.
Agent harness
The software around a model that turns it into an agent: the loop, tools, prompts, context management, permissions and limits.
Context window
The maximum number of tokens a model can consider in one request, covering both the input you send and the output it writes.
ReAct
A prompting pattern where a model alternates between writing out its reasoning and taking an action, then reads the observation before the next step.
Tool calling
A model emitting a structured request to call a defined function, which your code runs and whose result is then fed back to the model.
Durable execution
Running code so that its progress is recorded step by step, letting it resume after a crash or restart instead of starting again.
Read more about Agent loop
- AI agents
Building systems where models plan and call tools in a loop to complete tasks.