Browse notes
Agent Loop
In an agent loop, the model is not following a closed sequence of predefined steps. It observes the available state, chooses an action, receives the result, and decides again with that new information.
Coding-agent example
An agent is asked to fix a failing test:
- It runs the test and observes the error.
- It reads the test and related code.
- It edits a file.
- It runs the test again.
- If it still fails, the new error determines what to inspect next.
- If it passes and the task is complete, the agent stops.
The number of reads, edits, or test runs was not fixed at the start. Each result changes the information available for the next step.
Tools and execution
The model normally expresses an action as a tool call. The harness performs the operation — for example reading a file, changing code, or running a test — and returns the result as a new observation.
A sequence that uses tools is not necessarily agentic. In a fixed workflow, the operations are defined in advance. In an agent loop, the result of one operation can change which action is chosen next.
Stopping
The stopping condition needs to match the complete task. If the request requires fixing a test and running the build, a passing test still leaves one validation step outstanding.
The loop can also stop because it needs a user decision, an action requires approval, or no useful progress is possible with the available information. Repeating the same command after the same failure adds no evidence; the next step should change the hypothesis, ask for help, or stop.