Smart Token Compression
TokenJuice - a multi-stage compression router that compacts verbose tool output before it ever enters LLM context.
The pipeline, step by step
raw tool result
│
â–¼
1. Size gate router enabled? input ≥ min_bytes_to_compress (2 KB)?
│ yes
â–¼
2. Detect kind Json · Diff · Html · Search · Code · Log · PlainText
│
â–¼
3. Select compressor one specialized compressor per kind (+ per-kind toggles)
│
â–¼
4. Compress run it; if it declines or grows the output, fall back / pass through
│
â–¼
5. CCR eligibility lossy AND ≥ ccr_min_tokens (≈500)? → offload original to cache
│
â–¼
6. Append marker ⟦tj:<hash>⟧ footer so the agent can retrieve the full original
│
â–¼
7. Record savings tokens + cost saved, by model and by compressor
│
â–¼
compact text → LLM contextThe compressors
Compressor
Kind
What it does
ML compression (opt-in)
Nothing is lost: CCR cache & retrieval
Savings tracking
The rule overlay (command & log output)
Layer
Path
Purpose
Configuration, RPC & tools
Why this matters
See also
Last updated