Vibe coding · Debugging with AI · For beginners
AI Keeps Failing to Fix the Same Bug? Stop at Attempt Two
The third “you’re absolutely right, let me fix that” is where you start losing.
What a research paper on “debugging decay” and Anthropic’s own Claude Code docs say about AI fix loops — and the reset prompt that gets you out.
You know the feeling. The button still doesn’t work. You paste the error back in. The AI apologizes — warmly, confidently — and rewrites half a file. You run it. Same error. Or a new one. You paste that in too. Twenty minutes later you’re on attempt six, the chat is a mile long, and you’re no longer sure which version of the file was the “almost working” one.
It’s tempting to think the next try will be the one. The evidence says the opposite: each extra attempt in the same chat tends to help less than the one before. The fix isn’t a smarter sentence. It’s knowing when to stop and start clean.
The short version
If an AI coding assistant has failed to fix the same bug twice, don’t ask a third time in the same chat. A 2025 study of 18 code models found most lose 60–80% of their debugging effectiveness within 2–3 attempts. Anthropic’s Claude Code docs give the same advice: clear the chat and write one better prompt.
How I put this together. On Nov 14, 2026 I read the full paper behind the “debugging decay” idea (Adnan & Kuhn, The Debugging Decay Index, arXiv, revised July 13, 2025) and Anthropic’s official Claude Code best-practices page. Every number below comes from those two sources, and I link them where I use them.
What I did not do. I didn’t run my own experiment on today’s models, and this post isn’t based on one dramatic bug of mine. The “percent left” figures in the table are my arithmetic from the paper’s formula, and I say so where they appear.
Why AI actually gets worse at fixing the same bug
An AI chat has no memory outside the conversation. Every time you send a message, the whole conversation is sent back to the model — your first request, its first wrong fix, your “still broken,” its second wrong fix, all of it. So by attempt four, the model is reading three failed solutions every time it thinks about the problem.
That causes two quiet problems. First, the wrong ideas are now part of the evidence. If attempt one assumed the bug was in the login code, attempts two and three tend to keep poking at the login code — even when the real cause is somewhere else. Second, the useful facts (the exact error, what “working” looks like) get buried under pages of rewritten code.
Anthropic describes this directly in its Claude Code docs: after two failed corrections, a third one mostly adds to a conversation with “two failed attempts for Claude to keep re-reading.” You’re not just asking again — you’re asking with more bad evidence in the room.
Notice what that means: it’s usually not that the chat “ran out of memory.” Anthropic’s same page says most current models have a 1M-token window and compact long chats on their own, so running out is rare. The problem is what’s in the window, not how full it is.
What “debugging decay” means, in plain English
In 2025, two researchers, Muntasir Adnan and Carlos C. N. Kuhn, measured what happens when you let a model keep debugging its own code (arXiv 2506.18403). They tested 18 models on HumanEval, a standard set of small Python programming problems, and tracked how much each new debugging attempt still helped.
The pattern was an exponential drop — the same shape as a battery draining fast at first. Their headline: most models lose 60–80% of their debugging capability within just 2–3 attempts. They named the measurement the Debugging Decay Index.
Here’s how fast that drain is for a few of the models they measured. The paper gives the decay rate; I turned it into “how much is left after two attempts” so you can feel it.
| Model (as tested) | Decay rate (λ, paper) | Effectiveness left after 2 attempts (my math) |
|---|---|---|
| gpt-3.5-turbo | 1.33 | about 7% |
| llama3.1:8b | 1.11 | about 11% |
| deepseek-coder-v2:16b | 0.97 | about 14% |
| qwen2.5-coder | 0.46 | about 40% |
| codestral:22b | 0.34 | about 51% |
The part that matters most: starting fresh helped
The researchers then tried a “fresh start”: once a model’s effectiveness had dropped past a threshold, they wiped the conversation and gave it only the original problem again. Within the same budget of six tries, that lifted results for most models they reported — for example llama3.1:8b went from 72.56% to 82.32% of problems solved, and deepseek-coder-v2:16b from 84.15% to 92.07%, with similar or fewer tokens. Same model, same problem — the clean slate did the work.
⚠️ The catch
These were mostly older or small models solving short puzzle-style problems — not today’s top tools working inside your real app. Claude 3.7 Sonnet solved everything so fast it had no decay curve at all, and GPT-4’s curve fit poorly. Fresh starts didn’t help every model either: two got slightly worse at one of the thresholds tested. Treat “60–80%” as a strong pattern, not a law for the tool you use today.
The two-strike rule: when to start a new chat
Put the research and the official advice together and you get a rule simple enough to follow at 1 a.m.: two failed fixes for the same bug, then stop. Anthropic’s docs put it almost word for word — after two failed corrections, run /clear and write a better prompt instead of a third.
Some signs you’re already in a loop, even if you haven’t been counting:
- The AI says “you’re right” and offers a fix that looks a lot like one it already tried.
- The error flips back and forth between two messages as each fix undoes the other.
- It “fixes” the bug by deleting the feature, skipping a check, or wrapping everything in code that hides the error.
- You can’t tell anymore which of the AI’s file versions is the one you’re running.
Those aren’t findings from the paper — they’re the everyday symptoms of the same thing: the chat is now steering by its own earlier mistakes.
How to start over without losing what you learned
“Start a new chat” sounds like giving up. It isn’t — the failed attempts taught you things. The trick is to carry over the lessons, not the transcript.
- Stop the AI. In Claude Code, press
Esc. In other tools, just stop sending messages. - Undo the broken edits. Get back to the last version that worked, so the new chat starts from solid ground. In Claude Code,
/rewind(orEsctwice) rolls code and conversation back — but Anthropic warns it doesn’t restore files changed only by terminal commands. My guide to undoing AI changes that broke your working code covers every tool’s undo. - Write down three things. The exact error (copied, not paraphrased — here’s how to read error messages when you can’t code), what you expected to happen, and what the AI already tried that didn’t work.
- Open a clean chat.
/clearin Claude Code; “New chat” or a new agent tab in Cursor, ChatGPT or similar tools. - Send one better prompt — the reset prompt below.
The reset prompt (copy and fill in)
The bug: [what you do] → [what happens]. Expected: [what should happen].
Exact error:
[paste the full error message]
Already tried, did NOT work (don't repeat these):
- [attempt 1 in one line]
- [attempt 2 in one line]
Before changing any code, list your top 3 guesses
for the cause, most likely first, and how we could
check each one. Then fix only the most likely one.
"Fixed" means: [a check I can do, e.g. "after a page
refresh, the saved item is still in the list"].The “already tried” list is deliberate. The paper’s fresh start used only the original problem; Anthropic’s docs suggest a new prompt “that folds in what you learned.” A short list gives you both: a clean chat, minus the pages of wrong code, plus a fence around the dead ends.
Make the AI prove the fix instead of saying it
A lot of loops happen because the AI declares victory and you’re the one who has to test it. Anthropic’s docs call this out: if Claude has nothing to run that says pass or fail, “looks done” is all it has — and you become the test suite.
You don’t need to write tests yourself to use this. You need to describe a check in plain words — “when I click Save and refresh, the item is still there” — and ask the AI to tell you how it verified that, or to add a small automatic test that fails before the fix and passes after. A fix you can check beats a fix that sounds confident.
💡 Stop the same mistake from coming back
Anthropic lists “anything you’ve had to correct twice already” as something worth writing into your project’s CLAUDE.md file, so the next session knows it from the start. Here are 5 rules for a CLAUDE.md that actually makes Claude smarter.
The honest limitations
The study is one paper, on one benchmark of small Python problems, mostly with models that are a generation or more behind what you’re using now. The authors themselves say the numbers are specific to that dataset and can’t be compared directly across other problem sets. The paper also has some internal slips — the text mentions six models where the results table lists ten, and says every model improved where the table shows two small drops. None of that breaks the main pattern, but it’s why I’d call the two-strike rule good practice backed by evidence, not a precise law. I also haven’t measured how fast today’s Claude, GPT or Gemini models decay inside real apps; as far as I know, nobody has published that cleanly yet.
Who should actually care
Worth it if: you build with Claude Code, Cursor, Lovable, Bolt or ChatGPT and regularly find yourself 30 messages deep on one bug — especially if you pay per message or per credit.
Maybe not if: your bugs usually die on the first or second try. The rule only kicks in when a fix fails twice.
Skip if: the AI can’t see the real problem at all — a missing API key, a service that’s down, a setting only you can change. No number of fresh chats fixes what the AI can’t reach.
FAQ
How many times should I ask AI to fix the same bug?
Twice in the same chat. If the second fix fails, undo the broken changes, open a clean chat, and send one prompt with the exact error and what already failed. That matches both the research and Anthropic’s advice.
Does starting a new chat delete my code?
No. Clearing the chat clears the conversation, not your files. Your project stays exactly as it is — which is why you should undo the broken edits before starting fresh, or the new chat inherits the mess.
Is this because the AI’s context window is full?
Usually not. Anthropic says most current models have a 1M-token window and summarize long chats on their own. The issue is that the window is full of failed attempts the model keeps re-reading.
Should I switch to a different AI model instead?
It can help, since a different model doesn’t share the first one’s wrong assumptions — but the paper didn’t test switching models, so I can’t give you numbers. Try the reset prompt first; it’s free and it works with any tool.
The bottom line
When AI keeps failing to fix the same bug, the next message in that chat is the worst place to look for the answer. The research shows each extra attempt helps less; Anthropic’s own docs say clear and re-prompt after two. Two strikes, undo, clean chat, one better prompt.
Your next step: copy the reset prompt above into a note right now, so it’s waiting the next time you hit strike two.
Related free AI guides
- AI broke my working code: how to undo it in any tool
- How to read error messages when you can’t code
- App works locally but not after deploy? 5 causes and fixes
Published Nov 14, 2026. Sources checked Nov 14, 2026: arXiv 2506.18403 (v2) and Anthropic’s Claude Code best-practices page.