Your agent says it fixed the bug. You run it, the same error comes back. It says it sees the real problem now, changes the file, and hands you the same error again.
Twenty minutes later it is undoing the edit it made ten minutes ago. This chapter teaches you to catch that circling early and break it before it eats your whole session.
7.3.1Recognize a retry loop
A retry loop is when the agent keeps shipping variations of the same broken fix, each time sure it has it. The tell is repetition:
- the same edit made, reverted, and reapplied
- the same error message coming back unchanged
- a confident "now it is fixed" that is not
Catch it by the second round, not the fifth. It usually reads like this:
7.3.2Why the agent goes in circles
It is not being lazy. It lost the thread. The window is now full of its own failed attempts, so it keeps pattern-matching on those instead of the real cause. Those are the same dead ends you saw poison a drifting session in the chapter on managing what the agent sees.
The other cause is a wrong mental model. It is reasoning from one false assumption that nothing in the chat corrects, so every fix is internally sensible and still wrong.
7.3.3Break the loop
Stop it before the fourth attempt. Then do one of two things: hand it the fact it is missing, or force a fresh diagnosis before it touches a single line.
The missing fact is usually something only you can see. The real error in the browser console. The actual value of a variable. Or that the file it keeps editing is not the file that runs.
One such fact ends more loops than ten more retries.
7.3.4Reset the context and retry
If it has already churned through three attempts, the window is carrying every one of them, and one more message rarely pulls it out. Start a fresh session, the way the context chapter describes, and open with the missing fact plus a clean ask.
This prompt forces a ranked diagnosis before any edit, which is what actually breaks the loop:
Do this now: next time the same error returns twice, stop the agent, open a fresh session, and paste this prompt with the one fact only you can see.