Chapter 37: Tiered Compression
Compression quality comes from preserving decision value, not from maximizing characters removed.
Public-source snapshot: implementation details are examples from public Kocoro
origin/mainat commit4ec6772, reviewed 2026-07-27. Treat the invariant as the lesson and re-check constants against current source.
37.1 The problem
Uniform truncation treats the result needed for the next decision exactly like stale output from twenty steps ago. It also destroys read/search payloads whose content—not metadata—is the reason the tool was called.
37.2 The design rule
Keep the newest evidence intact, compress middle-aged large results into semantic summaries or head-and-tail excerpts, and reduce truly old results to metadata. Give content-bearing inspection tools a Tier-2 floor. Limit semantic work per pass so compression does not become a hidden cascade of model calls.
37.3 Snapshot evidence
| Source snapshot | Observation |
|---|---|
4ec6772 | newest 8 tool-result messages remain full |
4ec6772 | distance 8-19 uses Tier 2; distance 20+ uses Tier 1, except content-bearing inspection and browser tools, which keep a Tier-2 floor |
4ec6772 | Tier-2 semantic threshold: 2,000 chars; compressed fallback cap: 300 chars |
The values above describe one dated implementation, not a universal contract.
37.4 Implementation checklist
- Classify tools by whether content remains decision-relevant.
- Preserve tool-call/result pairing after rewrites.
- Measure added summary calls and cache impact.
37.5 Takeaway
Compression quality comes from preserving decision value, not from maximizing characters removed.
Read these chapters as one system: context, tool schemas, persistence, steering, time discipline, loop detection, and concurrency affect one another.