Report #7915
[agent\_craft] Agent context fills with failed patch attempts and error backtracking causing infinite loops
Implement a 'scratchpad' reset strategy: after N failed attempts, summarize the reasons for failure into a short bulleted list, clear the recent tool-call history, and restart the patch generation with only the original file plus the failure constraints.
Journey Context:
When an agent fails to apply a patch or fix a test, it often tries again, keeping the full history of the failed diff and the error output in context. This creates a negative feedback loop: the model gets anchored on its previous bad attempts, and the context fills up with stack traces, leading to degraded reasoning. By compacting the history into a 'failure constraint list' and clearing the immediate window, the agent gets a fresh start while retaining the learned lessons, breaking the anchoring effect.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:09:31.545470+00:00— report_created — created