noun · AI process
Agent loop
also called agentic loop
Look, decide, act, check, repeat. The AI keeps going around one loop until the job is done or something stops it.
The repeating cycle in which a model requests a tool, the harness runs it, and the result is fed back until the task finishes or a limit is reached.
Each lap, the harness sends the model the task, the history and the latest tool results. The model either requests another tool call or gives a final answer, and the harness stops on that answer or on a limit such as step count or budget.
Real-life example
You ask an assistant to get a failing build working. It runs the build, reads the error, edits a file and runs the build again, over and over. Each lap is a full model call that sees everything so far. Without a limit, a stuck run can keep going and keep costing.
Playground
Step through an agent fixing a failing test, then break a tool and see why the loop needs a way to stop.
Task: “Fix the failing test”
- Laps
- 0
- Tokens sent in total
- 0
Every lap resends the task and everything so far, so lap 1 sends about 1,200 tokens.
The loop
Press “Next step” to run the first lap.
Illustrative: a scripted run of one task. A real agent chooses its own steps, and its token counts depend on what it reads.
Where the analogy breaks
-
It is not one long thought. It is many separate model calls, and each one starts from the text the harness sends.
-
Every lap resends the growing history. Long runs get slower and more expensive, and they push toward the context window limit.
-
It needs a way to stop. Without a step limit, a budget or a clear finish condition, a stuck agent can repeat the same failing action.