Printed on demandShips worldwide14-day returns

“Let Me Fix That”: Why AI Coding Agents Get Stuck in a Loop

An AI coding agent finds a bug and says: “Let me fix that.” It edits the code and runs the tests. They fail. “Let me fix that again.” They fail again. The loop goes on until you stop it or the usage limit does.

Our shirt is that loop as a round badge: let me fix that again around the edge, and in the center attempt 3/∞ and tests: red.

Why the agent loops

A coding agent works in a cycle: change the code, run a check, read the result, change the code again. That cycle is what makes it useful. Anthropic’s Claude Code best practices say: “If you give it something that comes back pass or fail, Claude can close that loop itself.”

The same cycle goes wrong when each attempt starts from a bad idea. Every failed try stays in the conversation, so the next try is built on top of the last mistakes. The agent is confident each time, because it only sees one more small change to make.

Anthropic saw the end of this pattern in testing. The Claude 3.7 Sonnet system card describes a model that “typically follows a pattern of first attempting multiple general solutions, running tests, observing failures, and debugging”. After repeated failures, it sometimes cheated on the tests: see All Tests Passing. The card suggests monitoring for “excessive edit / test-execution cycles on a single file”.

Signs you are in the loop

SignWhat it means
The same file changes three or more times for one bugThe agent is guessing, not reasoning
The fix undoes the previous fixIt is going in circles
New errors appear in code that workedEach attempt adds damage
It apologises and promises it has found the real causeIt said the same thing last time

How to break the loop

The official advice is short. The best practices say: “press Esc the moment Claude drifts, and after two failed corrections run /clear and write a better prompt instead of a third.”

  • Stop early. Attempt 2 is cheaper to throw away than attempt 7.
  • Start a clean session and write what you learned: what failed, and why.
  • Give the agent the error output and the right file, not the whole repository.
  • Ask for a plan first and read it before any code changes.
  • If the bug is hard, debug it yourself for ten minutes. Then hand the agent the cause, not the symptom.

Why developers laugh at it

Because we do it too. Change one line, run it, still broken, change it back, run it again. The agent does it faster, with more confidence and with a polite apology each time. The counter on the shirt says attempt 3 of infinity, and everyone who has watched an agent work knows the infinity is not a joke.

The loop often ends when your plan runs out: see Usage Limit Reached. Or when the context fills up: see It Works in My Context Window.

Get the shirt

Let Me Fix That Again T-Shirt, front

Let Me Fix That Again T-Shirt · 24 €
Attempt 3/∞, tests: red.

Usage Limit Reached T-Shirt, front

Usage Limit Reached T-Shirt · 24 €
How the loop usually ends.

It Works in My Context Window T-Shirt, front

It Works in My Context Window T-Shirt · 24 €
The other way it ends.

All shirts are unisex, S to 5XL, printed on demand in black, graphite heather and white. Check the size guide before ordering. More ideas in the Christmas gift guide for programmers.

FAQ

Why does my AI coding agent keep making the same mistake?

Every failed attempt stays in the conversation, and the next attempt builds on it. A clean session with a better prompt usually works better than one more correction.

When should I stop the agent?

Claude Code’s best practices say: after two failed corrections, run /clear and write a better prompt.

Is the loop dangerous?

It can be. After many failed attempts, agents sometimes change or skip the tests to make them pass. Always read the final diff.