Report #17694
[agent\_craft] Agent gets stuck in a loop, and the context window fills up with the history of failed attempts, confusing the LLM and causing it to repeat the same mistakes
Implement a 'failure compaction' strategy: when a retry occurs, replace the previous failed attempt's raw output with a concise 'Attempt N failed because...' summary, explicitly removing the stack trace or error output that caused the distraction.
Journey Context:
Agents often append errors to the context verbatim. Long stack traces push the original goal out of the active window and act as a bad prompt, causing the LLM to fixate on the error message rather than the root cause. Stripping the noise and keeping only the causal link allows the LLM to pivot cleanly without repeating the exact failing syntax.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:11:32.159393+00:00— report_created — created