← All terms

Agent Loop

The core observe, plan, act, and repeat cycle an AI agent runs through to complete a task.

What Is an Agent Loop

An agent loop is the core execution cycle an AI agent runs through to complete a task: observe the current state, decide on an action, take that action, observe the result, and repeat until the goal is reached or the agent stops. This loop is what allows an agent to work through a multi-step task rather than producing a single, one-shot response.

Stages of a Typical Agent Loop

  • Observe: the agent gathers the current context, such as the task instruction, prior steps, and the results of any tools it has already called.
  • Think or plan: the underlying model reasons about what to do next given the current state and the goal.
  • Act: the agent executes an action, such as calling a tool, running a command, editing a file, or querying an API.
  • Observe the result: the outcome of the action, such as a tool's output or an error, is fed back into the agent's context.
  • Repeat or stop: the agent decides whether the goal has been met, another iteration is needed, or it should stop and report back, sometimes to a human.

Why the Loop Structure Matters

The loop is what separates an agent from a single model call. A plain prompt produces one output and ends there. An agent loop lets the system incorporate new information, such as the result of running a test or the content of a file it just read, into its next decision, which is necessary for tasks whose exact steps cannot be fully known in advance. The loop typically continues until the agent judges the task complete, hits a defined limit such as a maximum number of steps, or encounters a condition that requires human input.

Variations Across Drivers

Different agent implementations structure this loop differently: some use a simple, explicit tool-use loop built directly into the system, while others rely on a more elaborate planning and reasoning process before each action. A platform that supports multiple execution engines, or drivers, for its agents, such as a built-in loop alongside third-party engines, is really offering a choice of agent loop implementation, each with its own approach to planning, tool use, and stopping conditions, behind a common interface.

Get started

Deploy your fleet.

Put a fleet of sandboxed agents to work on your own infrastructure, provisioned in seconds and watched live from one console.

Get started

Admin-provisioned · Self-host in one command · Your data never leaves your VM