The agent is not a long answer but a closed loop. It connects your instruction, the chosen model and a set of tools: searching and reading files, editing, the shell, the web, the browser, image generation and questions to you. At every step it decides what to do next based on the result of the previous one: a call returns data, the data changes the plan, the plan produces the next call. Understanding that loop matters more than any wording tricks: it explains why the agent sometimes confidently goes the wrong way and why you need to be able to stop it.
The naive expectation is that the loop has a built-in limit of good sense: it will know when to stop. The documentation sets no limit on the number of tool calls in one task, and that is honest: the practical boundary is set by you. It is made of four things - the size of the context, cost, the permissions granted and your time for checking. Of those, only permissions are set in advance and once; the other three are spent silently, and you usually notice them after they have run out. If no boundary is named, the agent will work until the task seems solved to it.
The message queue is an underestimated part of the interface. While the agent works you can queue the next message instead of interrupting the current turn; the queue can be reordered. There is also a separate gesture for an urgent correction: the clarification attaches to your last message and is taken into account immediately. The difference between those two ways matters. The queue preserves the trajectory: the agent finishes the step it started and takes the next assignment with the observations it has already gathered. An urgent insert arrives in the middle of the reasoning and rewrites the goal halfway, while part of the observations were gathered for the old task.
It helps to see once what a good finish to a task looks like. Below is a short checklist: the agent listed the changed files and explained the cause, the diff was reviewed by hand, the check commands were taken from the repository rather than invented, test results are given with an exit code or clear output, and what was not verified is named explicitly. That last item is what separates an honest report from a cheerful one.
Checkpoints make the loop reversible. Snapshots are created before significant changes, and they can be previewed and restored - a local undo mechanism separate from git. It removes the fear of experimenting: a bad trajectory can be rolled back and the task reformulated instead of layering fixes on a wrong foundation. But after restoring, the working tree is still checked: a snapshot answers for the agent's changes, not for everything that happened in the directory.
Hence the practical technique that saves the most time. If an implementation went the wrong way, it is cheaper to restore the state, sharpen the task and run again than to fix on top. Layered fixes create a diff in which you can no longer tell what was intent and what was compensation for a mistake; such a diff costs more to read than redoing the work with a clear formulation.
A separate skill is noticing in time that the loop has stalled. The signs are recognizable: the agent repeats the same command with cosmetic variations, starts editing the test instead of the code that test caught, or widens the working area because no solution is found in the original one. All three follow from one thing: the hypothesis has run out while the loop continues. At that moment it is cheaper to stop the run and give the agent what is missing - a reproduction, a contract, the exact error text - than to wait for it to find that by trial and error.
Snapshots have a boundary that is easy to hit. They answer for the agent's edits to files, but they do not undo the side effects of executed commands: installed packages, built artifacts and changed data stay where they are. A snapshot is therefore a convenient undo inside one task, not a return point for the whole body of work. The anchor remains the commit: it fixes a state you can reason about, survives a restart of the editor and is visible to the rest of the team.
The engineering conclusion about the loop is simple: control comes not from prohibition but from three habits. Limit the scope of the task in advance, interrupt when you see the agent repeating the same failure without a new hypothesis, and demand evidence instead of assertions. A loop with those three things stays a tool; a loop without them turns into a stream of edits you can only watch.
The typical failures with the agent are predictable. Letting it go without boundaries and getting many changes instead of one verifiable change. Interrupting with urgent inserts where the queue would have been enough and knocking a found trajectory off course. Taking the final message for proof without opening the diff. And relying on a checkpoint as a replacement for a commit.
A good finish to an agent task
[ ] the changed files are listed and the reason for the edit is named
[ ] the diff was reviewed by hand, not through the final message
[ ] the check commands come from the repository rather than being invented
[ ] test results are given with an exit code or clear output
[ ] the unverified parts are named explicitly