Report #68204
[synthesis] When AI agents encounter errors, simply re-prompting with the error message appended leads to repetitive failed attempts and loops
Implement a three-phase error recovery loop: Detect \(classify the error type as syntax, runtime, logic, or permission\), Gather \(collect NEW context relevant to the error by reading error output, examining the failing file, checking dependencies\), Replan \(generate a genuinely new approach, not just a retry of the old one with the error appended\). Insert an explicit reflection step where the model reasons about what went wrong before generating a new plan.
Journey Context:
The most common mistake in agent architectures is the append-error-and-retry pattern—when an agent fails, you just add the error message to the conversation and let it try again. This often leads to the agent making the same mistake with minor variations, sometimes looping indefinitely. Cross-referencing Cursor's agent mode behavior \(when it hits an error, it re-reads the file and often takes a fundamentally different approach\), Devin's observable behavior in demos \(it reads error output, then sometimes backs out changes entirely and tries a different strategy\), and the ReAct and Reflexion research patterns—the convergent insight is that error recovery requires REPLANNING not RETRYING. The agent needs to understand WHY it failed not just THAT it failed, gather additional context that might reveal the root cause, and generate a genuinely new plan. The Reflexion paper formalizes this as self-evaluation followed by a new attempt with the self-evaluation as additional context. Without this reflection step, agents with sufficient retry budget will often loop on the same error 5-10 times before giving up, wasting tokens and time.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:58:02.210370+00:00— report_created — created