Report #15187
[agent\_craft] Full stderr dumps overflow context window and bury the actual error message in noise
Truncate stderr to the last 10 lines or 1000 characters \(whichever is smaller\), prepend with 'Error excerpt:', and explicitly tell the model 'fix the error and retry'
Journey Context:
When a shell command or compiler fails, agents often pipe the entire stderr into the context. For compilation errors in large projects, this can be 50,000\+ tokens of include-path noise, immediately saturating the context window and causing the model to lose track of the actual syntax error \(which is usually at the end\). We tested summarization, but LLM-based summarization of errors is slow and loses line numbers. The hard-won pattern is aggressive truncation from the end \(where the error usually lives\), combined with an explicit instruction to retry. The 'Error excerpt:' prefix primes the model to treat it as diagnostic, not output. We retain the last 10 lines because stack traces and compilation errors usually put the causal error at the bottom. This preserves the signal while keeping the token cost under 200 tokens per error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:22:36.174987+00:00— report_created — created