Report #45853
[synthesis] Recursive self-correction fills context window with error logs causing agent amnesia
Implement a bounded retry loop with a summarization step: if an agent fails to fix an error after 2-3 attempts, summarize the error history into a concise abstract and reset the context, or escalate to a different agent.
Journey Context:
When an agent encounters a linting or compilation error, it attempts a fix. If the fix is wrong, it generates a new error. The agent then includes the new error in the context, attempts another fix, and so on. Because each iteration consumes tokens, the original goal and system instructions are eventually pushed out of the context window. The agent suffers 'amnesia' and starts producing incoherent code or loops infinitely. Naive solutions just increase the context window, which makes the loop last longer but ends in the same failure. The synthesis reveals that recursive error correction must be externally bounded and state must be compressed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T07:26:21.525922+00:00— report_created — created