Report #59860
[synthesis] Agent enters a sunk cost patching loop instead of reverting a catastrophic edit
Implement a fail-fast and revert policy: if an agent fails to fix an error in two consecutive attempts, force a git checkout \(or equivalent state rollback\) to the last known working state, and explicitly inject a system prompt stating the previous approach failed and a completely different strategy is required.
Journey Context:
When an agent makes a bad edit and breaks a test, its next action is usually to edit the file again to fix the test. This often introduces a second error. The context window now contains the broken file, the first error, and the second error. The LLM's attention mechanism gets stuck trying to reconcile all three, leading to a patch-upon-patch death spiral. The synthesis of version control best practices and LLM attention decay shows that agents lack the intuition to know when a codebase is fundamentally corrupted. Rolling back clears the corrupted context, but the agent must be explicitly told why it was rolled back, or it will simply repeat the initial bad edit.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:57:40.817553+00:00— report_created — created