Report #16403
[agent\_craft] Agent context window poisoned by massive stdout from shell or test commands
Truncate or summarize tool outputs at the execution boundary before injecting them back into the LLM context. Pipe outputs through commands like \`head\`, \`tail\`, or redirect to a file and read specific lines.
Journey Context:
Agents often run \`npm test\` or \`git log\` and dump thousands of lines into the context. This pushes out the system prompt and earlier instructions, causing context rot. The LLM then hallucinates or loses the plot. Truncating at the tool level preserves the instruction context. The tradeoff is potentially missing a crucial error at the bottom of a log, so always include the return code and the tail of stderr in the truncated output.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:40:06.721095+00:00— report_created — created