My AI keeps looping on the same error: how to stop it
It fixes it. Nothing changes. It fixes it differently. Still nothing. It goes back to the first fix. You have been watching it spin for twenty minutes, the same files keep scrolling past, and you dare not interrupt in case the next attempt is finally the right one.
An AI loops when the task has no stopping condition. It tries, fails, and nothing tells it when to give up. Interrupt it, make it explain why the first attempt failed before proposing another, and set an attempt limit in your instructions. The loop disappears.
Why it starts over indefinitely
An AI that codes does not know it is going in circles. It treats every attempt as a fresh request: no counter, no memory of the previous failure, no fatigue.
The trigger is almost always the same — a request with no stopping condition. “Fix this bug” never says when to give up. So it tries one approach, sees it fail, tries another, comes back to the first in a slightly different form, and on it goes. Each attempt feels new to it.
The pattern is well enough known that tools guard against it: the official documentation describes a mechanism that cuts in automatically when an operation repeats without progressing, precisely to avoid burning calls on a loop going nowhere.
The three sentences that break the loop
Interrupt first — the escape key or Ctrl+C depending on your tool. You lose neither the conversation nor your work, only the operation in flight.
Then, in order:
“Do not try another fix. First explain why the first one failed.” This is the important one. It forces a diagnosis where there were only attempts. Nine times out of ten, the explanation reveals the problem was not where it was looking.
“What have you already tried, and what did each attempt produce?” It lists them. You both finally see the pattern. And often it realises, while writing, that it tested the same thing twice.
“Go back to the state that worked before all this.” If twenty minutes have left traces everywhere, starting from a clean state costs less than untangling.
The cause nobody checks
When an AI cannot fix something after several genuine attempts, the problem is rarely the one it was shown.
It fixes what you pointed at. If the visible symptom comes from somewhere else — a setting that only applies after a restart, a file that is not the one actually being served, a value written in two places — it can repair the wrong spot indefinitely with total conviction.
Hence the question that unblocks the most situations: “Are you sure the file you are editing is the one producing what I see?”
The instruction that stops it coming back
Everything above works after the fact. The real saving is writing it once in the instruction file your tool re-reads at every start.
Two lines are enough:
If a fix does not work, do not try another one at random. First explain why the first failed.
Two attempts maximum on the same problem. Beyond that, stop and tell me what you tried.
The second is the one everyone forgets, and it is the one that removes the loop: a number turns a vague instruction into a checkable rule.
What it actually saves you
A twenty-minute loop does not cost twenty minutes. It eats your subscription, it leaves edits scattered across files you were not watching, and it drains the patience you will need for the next problem.
The worst part is what it does to your confidence: after three loops, you start believing the tool does not work. When it was doing exactly what you asked — carry on, without anyone ever telling it when to stop.
> add a contact form