Agent loop
Where it sits in the kitchen
The chef cooks, tastes and adjusts, again and again, until the dish is right.
Definition
The cycle that turns a model into an agent: look, act, see the result, repeat.
The model looks at its context and picks a tool to use. The harness (the app around the model) runs it and adds the result. The model looks again, until it reaches the goal and answers, or hits a limit on steps, time or money.
On long jobs, agents keep a to-do list. They should check their work, because errors add up: if each step goes right 95% of the time, a 10-step job goes right only about 60% of the time.
Detailed technical description
Research introduced the loop as ReAct (reasoning plus acting). On each turn the model either answers or asks for a tool call; the harness runs the tool and appends the result, called the observation. The loop ends with a final answer, a stop hook, a person interrupting, or a budget for turns, tokens, time or money running out. Current models think between tool calls and can make several calls in one turn.
Agents plan explicitly (a written plan a person approves) or implicitly (choosing the next step each turn). Many harnesses offer plan mode: read-only exploring that ends in a plan you review before anything changes. A to-do list keeps long tasks on track and survives when older steps are summarised (compaction). Skip plans for small tasks, and update them when reality changes.
Agents become more reliable with ground-truth feedback, outside checks that show what actually happened: compilers, tests, linters (automatic style and error checkers), a screenshot of the result, a schema check, or a second model reviewing against explicit criteria. Models cannot reliably correct their own reasoning without such a signal, so avoid self-review in the same context. Do not let the agent edit tests to make them pass; protect them with hooks or permissions.
Use the loop for open-ended tasks whose steps cannot be known in advance, and a fixed workflow where a fixed sequence would do. Always set stop conditions and budgets: clear, checkable goals make the loop converge; vague goals make it wander.
Planning & task lists: Breaking a goal into steps before acting, and keeping a visible to-do list while working.
Verification & self-correction: Giving the agent a way to check its own work, with tests, screenshots or a reviewer, and to fix what fails.