Report #96294
[agent\_craft] Full tool output \(test logs, build output, large API responses\) loaded into context consumes budget on irrelevant detail while the key information is at the beginning or end
Truncate all tool outputs to a maximum of approximately 200 lines or 4000 tokens. Always include both the head \(first 50 lines: command echo, headers, setup\) and the tail \(last 150 lines: final results, errors, summary\). Mark truncation explicitly so the agent knows to request more if needed. For structured outputs, extract only the relevant schema fields.
Journey Context:
Tool outputs from test runners, build systems, and API calls routinely exceed 1000 lines. Loading them entirely is almost always a mistake: the relevant information clusters at the end \(error messages, final test results\) and sometimes the beginning \(command invocation, environment headers\), while the middle is typically voluminous passing output. The head-plus-tail truncation pattern captures both critical zones while keeping context lean. The explicit truncation marker is essential—without it, the agent may assume it has seen the full output and reason incorrectly about what is absent. The risk of missing a key detail in the truncated middle is real but manageable: the agent can always re-run the command with filters \(grep on test output, --verbose flags toggled\) or request specific line ranges. This is far cheaper than burning 10K\+ tokens on every tool call output.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:12:46.876476+00:00— report_created — created