Guides

Stuck in an AI error loop? How to get out

To get out of an AI error loop, stop asking for fixes, revert to your last working commit, then give the agent the exact error text and one sentence on what should happen, and let it make one change at a time.

Updated

You know the loop. The agent says "Fixed!", you reload, and it's the same error. Or a new one. You paste "still broken", it tries again, and an hour later the page that half worked doesn't load at all. This is vibe debugging: fixing by feel, without telling the agent what is wrong or what right looks like. Here's how to get out.

1. Stop asking for fixes

Each "try again" adds changes on top of changes that didn't work. The agent also reads its own failed attempts in the chat and keeps building on them. The loop doesn't end by itself. The first step is to stop typing "still broken".

2. Go back to the last version that worked

If you use git, find the last commit where the page worked and go back to it. git log --oneline lists your commits. git restore . throws away changes you haven't committed yet. If you're not sure which command fits, the git undo helper picks the right one for what you want to undo.

If you didn't commit, commit now anyway so you have a point to come back to. Then ask the agent to list every file it changed for this bug, and undo them one at a time.

Throwing away an hour of changes feels bad. It is usually faster than untangling them.

3. Write down the exact error

"It doesn't work" gives the agent nothing to aim at. Get the real error text:

4. Say what should happen

This is the line people skip. Without it, the agent invents its own goal, and may "fix" the error by hiding it. Write one sentence: "Clicking Save should store the name and show a Saved message." Then add the scope: only this page, or everywhere.

Put it together in a fresh chat:

Page: localhost:3000/settings
What I did: changed my name, clicked Save
What happened: nothing, and this error in the console:
  TypeError: Cannot read properties of undefined (reading 'id')
Expected: the name saves and a "Saved" message shows
Scope: only this form
Please explain the cause before changing any code.

Asking for the cause first is a useful brake. If the explanation sounds wrong, you can say so before any files change. The guide on writing a bug report for an AI agent has a full template.

5. One change at a time

Small steps feel slower. They are how you stop going round in circles.

Give the agent the facts with Darnly

Step 3 and step 4 are the ones that break the loop, and they are the ones people skip when they're tired. Darnly is a free Chrome extension and Mac app that makes them quick. Press Option+Shift+B (Windows is coming soon), click the broken part, and type what you expected.

Darnly saves a report into .darnly/inbox/ in your project with a screenshot that has the broken part boxed in red, the page address, the element, and console errors and failed requests from the last 60 seconds. Your agent reads the exact error and your expected line from the file, instead of "still broken".

Questions

What is an AI error loop?

It is when your AI coding agent keeps "fixing" the same bug and each fix brings back the same error, or swaps it for a new one. Every round adds more changes on top of the last, so the code drifts further from anything that worked.

What is vibe debugging?

Fixing bugs by telling the agent "it's still broken" and hoping, without giving it the exact error or saying what should happen. It feels fast, but it is the usual way people end up stuck in an error loop.

Should I start a new chat?

Often, yes. A long chat is full of failed attempts the agent may keep building on. After you revert, a fresh chat with the exact error and the expected behavior is a clean start.

What if I never committed?

Commit now, even if it is broken, so you can at least get back to this point. Then ask the agent to list what it changed for this bug and undo those changes one at a time. From now on, commit every time something works.

How does Darnly help?

It writes the bug down for you: a screenshot with the broken part boxed, the page address, the element and recent console errors, saved into your project. That gives the agent the exact error and what you expected in one go.