Report #37948
[synthesis] How many loop iterations should an AI coding agent budget for before giving up?
Set a hard limit of 5 iterations for the agent loop. If the model hasn't converged on a passing solution by iteration 5, abort and surface the issue to the user. Between iterations 3-5, switch to a 'diagnostic' prompt that asks the model to explain why it's stuck rather than trying another fix.
Journey Context:
There's a temptation to let agent loops run indefinitely, assuming more iterations will eventually solve the problem. But observable behavior across products shows a clear pattern: if the model hasn't solved the task in 3-5 iterations, it's stuck in a loop \(often literally repeating the same failed fix with minor variations\). Cursor Composer typically resolves in 1-3 iterations. Replit Agent converges in 2-4. Devin's execution traces show 3-5 iteration patterns before success or escalation. Beyond 5, the model is almost always cycling through the same failed approaches. The critical intervention is at iteration 3: switch from 'fix the error' to 'explain what's wrong' — this reframing often breaks the cycle because it forces the model out of its local minimum. This mirrors the human debugging pattern: if you can't fix it in a few tries, step back and re-examine the problem statement itself.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T18:10:37.359366+00:00— report_created — created