Guide
How to compress agent tool output
Compress agent tool output at the boundary where it becomes model context. Keep required fields explicit, select relevant source spans, and retain the original result for later use.
Classify the result
JSON, logs, tables, diffs, and prose need different handling. Structural formats can use offsets and validity checks; prose needs provenance.
Preserve the contract
Keep IDs, statuses, errors, and envelopes required by the next tool call. Compression is not a schema or security boundary.
Compare equal ratios
A shorter output is not enough. Test whether the agent can still answer workload probes at the same kept ratio as a baseline.