SWE-bench Verified, live, four arms: 13% cheaper than no compaction, and the highest reward. See the numbers

What this branch measured, and what it changed

Every number here was produced on real Claude Code traffic through a local context-guru proxy, counted with internal/tokens (o200k) and priced at the tier the request actually billed. The harness is bench/ab.sh over apply/sweep_capture_test.go; the corpus is four captures of real interactive sessions (short 5 requests, long 35, mixed 21, cold 9 with real 430 s idle gaps, 3 of them verified cache_read == 0).

The measurement rules that bind every claim below

  1. Cold measurements need n>=3 and a range. Three identical runs of the same config on the cold arm gave 5.83% / 4.30% / 1.75% removed and net +$0.0097 / +$0.0026 / -$0.0086. The sign flips. A single cold number is noise.
  2. The value tier is a 12.5x lever. The 14,407-request production snapshot is 90.54% cache_read (this branch's own four captures are 86.86%), so a removed token is worth 0.209x fresh. At the $2.00/MTok this gateway billed the bench corpus that is $0.412/MTok. Two measurement tests hardcoded $0.6265, which is the same multiplier against Anthropic's $3.00 list rate and therefore ~1.26x high for this corpus; corrected. Component ranking is unaffected, absolute dollars in those tests were.
  3. removed > attempted is cache invalidation, not saving. Never counted.
  4. The baseline is zero. The shipped default removes 0 tokens on short, long and mixed; only 7-27% of a request lies outside the cached prefix.
  5. A harness bug invalidated our history. Coldness is computed only on the Tracker path, so CG_SWEEP_IDLE advanced the clock and changed nothing. Every earlier "cold-cache sweep" figure in this repo was measured warm. Fixed in d1dbd4e.

What improved, measured

change before after
extract_llm cold sweep, net -$0.039 +$0.0157 to +$0.0212 (all positive, n=6; median +$0.0172)
extract_llm code leg accepted (fixed 40-body corpus) 15/40 27/40 and 29/40 on two runs
extract_llm tokens removed 20.6% 45.6%
extract_llm spend per accepted extraction $0.0204 $0.0110
Components tab total saved (14,407-request snapshot) $0.0064 $5.7368
declaration filter, one real 35-request session n/a 12,754 tok/request, $0.1186 avoided
haiku extraction prompt caching never cached cache_creation 4217 -> cache_read 4217

The win is one fix, and it came from deleting our own work rather than adding any. A keep-list built from any 4+-letter word was harvesting English prose (against, including, large) into the KEEP set and then failing its own recall check on it: 13 of 40 calls refused a good compaction for "dropping" an English word. Reverting only that predicate returns the corpus to 17/40 with 14 acceptance-check rejections, so it is +9 of the +12 accepted.

An earlier draft of this document credited the cold-sweep turnaround to no longer forcing context: full. Independent re-measurement refutes that: on the fixed code full is also net-positive (+$0.0119, accepting 3/3), so the keep-list fix alone carries -$0.039 to about +$0.012 and dropping the force adds roughly +$0.005. The two changes were conflated.

New components, all shipped off and in no preset

component measured verdict
searchfold (lossless grep/find path folds, exact inverse) -31.7% on the 81 of 135 search-command outputs it fires on; small in aggregate (the 1.2%-of-tool-output-bytes figure has no committed command behind it) honest-small
textclean (lossless ANSI + \r) -17,219 tok = 1.73% of corpus (1,734 outputs / 996,453 tok); 92.1% of the mass it touches the only reformat item with real mass
toolschema (JSON-Schema annotation strip) 473 tok/req = 0.55-0.83%; break-even 880-2,062 requests does not pay warm
readlifecycle (stale/superseded Reads) 0 tokens warm; 33.0% of one cold request, +$0.031 cold only
toolfilter (unused declarations) 12,754 tok/request, $0.1186 on one session the largest measured win
skeleton (file-dump signatures) per dump, by arm: fire 50-100%, removal 8.2-59.1% (long 91.7%/51.8% is the best arm); $0.00 per live turn on all four must not be enabled
cmdfilter agent_filters: safe/lossy 4.23% / 7.41% on Python-test traffic; zero on all four interactive arms benchmark-only

What we proved is NOT there

hypothesis measured
the trigger gates out $744.62 counterfactual $0.028 SWE-bench / $0.00 interactive
half of requests are unfrozen, so act freely ~1,000:1 against; frozen=0 is our index reset, not a cold cache
the flattened one-message class is reachable 95.6% cache_read; 1,150:1 against; it is a classifier probe, not /compact
JSON record arrays are 89% of envelope mass zero fires; coding-agent output is 1,724 of 1,748 plain text
headroom's 75% of Read bytes is stale/superseded 21.1% stale, 0.0% superseded, 78.9% fresh — it inverts
Starlark syntax causes 63% of extraction failures 3/40 = 7.5%; the contract already worked
cmdfilter filters are the gap for Bash output 81-85% of it is file dumps, which have no lossless reduction

The structural finding

Every large token class is unreachable by a proxy, and each for the same underlying reason.

The moment information becomes safe to remove is the moment removing it costs a re-anchor.

This is also why rtk's largest lever does not transfer: it substitutes the command and shrinks output before it enters the transcript, so "is this the newest read" never arises. Same technique, opposite economics, purely because of where it sits.

And it is why toolfilter is the one item measuring in dollars: a session's first request is a cold start anyway, so filtering deterministically from turn 1 costs nothing.

Metric names that assert causes they do not measure

Four refuted premises above trace to this, so it is recorded as a rule:

A column computed downstream of an outcome cannot validate a predictor of that outcome, and a name containing a cause is a branch label, not a measured mechanism.

Bugs found that matter more than the savings

Honest position

Deployment net over the measured 3-day window was -$10.14: $7.07 gross saved against $17.22 of our own LLM spend. The extract fixes reduce the cost side and raise acceptance, but everything new in this branch ships off, so the deployed position does not move until something is enabled. The two candidates with a positive measured net are the cold sweep (+$0.020, sign-stable) and toolfilter ($0.1186 on one real session).

Production input is 90.54% cache_read and output is 8.086% of the bill, so addressable spend is 91.914% (this branch's four captures: 86.86% and 88.77%) — but a removed token is worth 0.209x fresh. Low-single-digit percentages of the addressable bill are what the transformation components can reach on this traffic. The order-of-magnitude item is removing declarations that are never used, because it is the only work that changes the prefix before it is ever cached.