MV

Agent Loop

An agent loop is a repeated cycle of inference, tool execution, and feedback through which an agent works toward a goal.

Diagram of an agent loop: context preparation leads to model inference, which either returns an agent response when done or requests tool calls. Tool results are appended to the context for the next cycle.

Each cycle starts with an inference request. The model consumes the provided context and produces an answer or requests tool execution through tool calls.

When tools are called, the application executes them and adds their outputs to the context alongside the corresponding tool calls. This feedback becomes available to the model in the next inference request, allowing it to use the results and decide what to do next.

The cycle continues until the model produces an answer without further tool calls, or the application stops or pauses execution—for example, when a limit is reached or human input is required.

Back to the glossary

Newsletter

Get new glossary entries and AI system patterns in your inbox.