Report #52578
[agent\_craft] Tool outputs \(logs, JSON blobs\) exceeding context limits or drowning relevant context
Apply a map-reduce compression policy: chunk tool outputs >4k tokens, summarize each chunk with an instruction to preserve error lines and key-value pairs, then inject the condensed version into context.
Journey Context:
Raw outputs from \`docker logs\` or \`SELECT \* FROM large\_table\` can be 100k\+ tokens. Naive insertion truncates the middle \(losing critical stack traces\) or overflows context. A map-reduce step treats the output as a document: split into chunks, summarize with specific constraints \('keep all ERROR lines, collapse INFO lines'\), then combine. This trades an extra API call for guaranteed context fitting. Simple head/tail truncation loses distributed errors; compression preserves them via instruction. Tradeoff: Adds 1-2s latency for the compression call; requires a secondary model \(can use Haiku/GPT-3.5 to save costs\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:44:44.925676+00:00— report_created — created