← All research

Context Compaction

Does compaction save Claude Code usage?

Mixed ResultsAI-assisted implementationNo independent review
Research questionDoes compacting the conversation context reduce Claude Code subscription usage without hurting task quality?
ResultNo saving on Sonnet 5.5 (0.96–1.52× full history); 0.33× on Haiku 5.5 above 100K tokens. Trimming the fixed per-call context mattered more.
Mixed results. Recommendation: adopt with conditions. Deliberate compaction did not reduce cost on Sonnet or Opus 5.5 at these task sizes, and a pre-registered prediction that it would pay off above 150K tokens was falsified. It did pay off on Haiku 5.5, whose price rises above 100K tokens. Cutting the fixed context sent with every call was the larger saving.

What this was based on

The starting point was NVIDIA's paper You Don't Need Long Context (Belcak et al., November 2026). It reports that compacting an agent's context often, replacing the history with a short brief and continuing in a fresh context, keeps accuracy while cutting cost. Its cost figures are modelled, not billed: the paper builds them from GPU throughput measurements and an assumed per-token price that rises with context length. Anthropic's prices for Sonnet and Opus 5.5 do not rise with context length, and Claude Code relies heavily on prompt caching, so it was unclear whether the saving carries over to a Claude Code subscription.

Background

Does compacting the context reduce Claude Code subscription usage without hurting task quality? If it does, for which model, at what context size, and with which compaction strategy?

Method

G0
Full history (baseline)
G1
Free-form brief at a threshold, then a fresh session
G2
The same, aggressive (10K threshold; pilot only)
G3
Single action per context (pilot only)
G5
Structured state plus a raw-history archive
GN
Claude Code's built-in /compact at the threshold
G6 / G0F
Full history with the author's real CLI setup: settings, hooks, plugins, MCP servers

Cost relative to full history (G0) Measured

Model · task (G0 peak context)G1G5GNG0F (real setup)
Sonnet T4 (98K)1.40 (0.90–1.82)1.52 (1.11–1.88)1.25 (0.57–1.86)1.93 (1.62–2.31)
Sonnet T3 (127K)0.96 (0.88–1.06)1.03 (0.93–1.19)1.14 (1.07–1.24)1.66 (1.63–1.71)
Sonnet T5 (235K)–0.99 (0.95–1.03)0.98 (0.94–1.03)–
Opus T4 (109K)–1.04 (0.93–1.17)––
Opus T3 (206K)–0.76 (0.65–1.01)––
Haiku T4 (147K)–0.73 (0.54–1.16)––
Haiku T3 (247K)–0.33 (0.30–0.36)––

Mean of 3 reps with a bootstrap 95% CI; below 1 is cheaper than full history. No compaction cell scored lower than G0. Sonnet T5 used a 150K threshold. In the short pilot (1 rep), G2 cost 1.31× and single-action compaction (G3) 4.72×.

Why the saving does not carry over Judgment

Information loss and failures Measured

A pre-registered prediction, falsified Measured

Phase 3 suggested that compaction pays off only when full history would exceed about 150K tokens. Before Phase 4 this was written down as a prediction: on a longer task (T5, peak 235K), G5 and GN with a 150K threshold would cost at most 0.8× G0 with no quality loss, and the prediction would count as falsified if both cost at least 0.95×. Result: G5 0.99× and GN 0.98×, with all 9 runs at full score. The prediction is falsified for Sonnet 5.5.

Recommendation: adopt with conditions Judgment

Limitations

Verification and AI use

The table figures were copied from the project's final report and its auto-generated Phase 3 analysis, which agree; the Phase 4 ratios were re-summed from the batch result files. The analysis was not otherwise re-run. AI-assisted implementation: an AI agent (Claude Code) built the harness, ran the experiments and wrote the analysis and report; the author set the question, approved the usage budget and chose the Phase 3 design. The models under test belong to the same family as the agent that ran the study. The literature review was web-based, and only the sources marked as checked above were confirmed against the original. Code and raw data are kept private. No independent review.