From our observations across 32+ sessions:
- Auto-compaction triggers at roughly 155k-165k tokens
- After compaction: ~5-6% context reduction (9k-13k tokens removed)
- Example: 197,406 → 184,374 preTokens = 13,032 tokens removed
Claude Code automatically compacts conversation history when context approaches limits. This summarizes older turns while keeping recent context intact.
From our observations across 32+ sessions:
Compaction is marked with a system message in session logs:
| Field | Meaning |
|---|---|
trigger | "auto" or "manual" |
preTokens | Token count before compaction |
You can manually trigger compaction with /compact. The stream-json output shows:
{"type": "system", "subtype": "status", "status": "compacting"}{"type": "system", "subtype": "status", "status": null}{"type": "system", "subtype": "init", ...}{"type": "system", "subtype": "compact_boundary", "compact_metadata": {"trigger": "manual", "pre_tokens": 18875}}After compaction:
From the result message usage object:
| Field | What it means |
|---|---|
input_tokens | New tokens sent this call |
cache_creation_input_tokens | Tokens written to cache |
cache_read_input_tokens | Cache hits (reused, cheap) |