Report #7487
[agent\_craft] Context window exhaustion during tool error recovery due to full stderr reinjection
Implement error summarization middleware: truncate stack traces to the last 5 frames, summarize error type and message in under 50 tokens, and never resend successful tool results from previous turns during error recovery loops; maintain a sliding window of only the last 3 turns of tool history
Journey Context:
Naive error handling sends entire stdout/stderr \(often thousands of tokens\) back to the model when a tool fails. On the second retry, the context is bloated with previous errors, leaving no room for the fix. The 80/20 rule applies: the error type and last few frames contain 80% of the debugging signal. Aggressive truncation \(last 5 frames\) plus a strict turn limit \(last 3 turns\) preserves context space for the solution while maintaining error causality.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:48:03.798547+00:00— report_created — created