---
title: "Agent loop"
url: https://www.daytona.com/definitions/a/agent-loop
---

# Agent loop

The agent loop is the cycle in which the model chooses an action, the harness executes it, and the result is appended to the history.

The agent loop is the cycle that an agent repeats while it works on a task. On each pass, the model receives the goal and the history so far. It chooses the next action and expresses it as a tool call. The harness runs the call and appends the result to the history.

The loop lets a language model act on the world instead of only producing text. Each result gives the model new information, such as command output, file contents, or a screenshot. The model uses that information to decide the next step. The loop ends when the model reports that the task is complete or when the harness reaches a limit, such as a step count or a time budget.

The agent harness owns the loop and decides which tools the model can call. Many tool calls run code or shell commands, so the harness often executes them in a sandbox rather than on the host. The history grows with every pass, so long tasks need ways to shorten or summarize the context. Multi-agent designs run several loops at once, with sub-agents handling parts of a larger task.

## Related terms

- [Agent harness](https://www.daytona.com/definitions/a/agent-harness.md)
- [Context](https://www.daytona.com/definitions/c/context.md)
- [Sub-agent](https://www.daytona.com/definitions/s/sub-agent.md)
- [Tool call](https://www.daytona.com/definitions/t/tool-call.md)
