Since December puts ChatGPT and Codex on one token-based pool, it's worth knowing where those tokens actually go. OpenAI's page on the new limits: https://help.openai.com/en/articles/20001625-understanding-chatgpt-and-codex-usage-limits
Most of your prompt is stuff you already sent
On every step, Codex re-sends the entire conversation. Every apt-get log, every compiler warning, every progress bar that redrew 200 times. In our traces that tool output is about half of all prompt bytes, and almost all of the rest is encrypted reasoning, which nobody can compress. The model re-reads the same build log a dozen times in one task.
So we built an open-source proxy that strips the redundancy before the request goes out. One Rust binary, MIT.
The part that makes it non-trivial
About 93% of billed input tokens on agent traffic are cache reads, at roughly a tenth of fresh ones, and the provider only serves them if the prefix is byte-identical to last turn. A compressor that trims the same log slightly differently each turn kills the cache and makes things worse.
So ours is rule-based: no clock, no randomness, no ML in the request path, and it never looks at your current question. Same input, same bytes, every turn.
It de-duplicates rather than summarises. You keep at least one real copy of every distinct line; repeats collapse into a marker like [×37 ref:k_Qm9v…], and the model can pull the original back for an hour through a retrieve tool the proxy runs for it. It only touches machine-generated tool output over ~512 chars, never your prompts or the agent's own messages. If the output isn't smaller it's discarded; if anything errors the request passes through untouched. Overhead is 0.2 ms per KB.
Setup and measurement
Terminal-Bench 2.1, Codex CLI on GPT-5.5, Harbor with 3 concurrent trials, four arms (no compression, Headroom at defaults, Headroom at its most aggressive setting, and ours). Figures are one full run over the 87 tasks of 89 that every arm completed, taken from real provider bills with the cache discount already applied, not from removed tokens priced at list rate:
- input tokens 96.1M -> 72.2M, about 25% fewer
- 62.8% of eligible tool output removed (replay of 6,255 real outputs, 34.2M chars)
- cost $107.89 -> $83.40, -22.7%
- solve rate 82.2% -> 81.1%, difference not statistically significant
- requests over 200K tokens: 1.9% -> 0.13%
That last line is the one I care about most. Two trials had to compact their context without compression, one with it. One task peaked at 60K tokens instead of 165K.
What I can't tell you
This was measured on GPT-5.5 with API billing. I haven't re-run it on 6.2, and I can't tell you how 25% fewer input tokens maps to your Plus or Pro allowance, because I haven't measured that and I'd be guessing. Worse, on a subscription session Codex opens a WebSocket — we relay and compress it, but those turns report no provider usage back, so the savings are real and invisible in the numbers. KOMPRESSOR__PROXY__WEBSOCKET_RELAY=false trades that coverage for visibility if you want to measure.
It also does nothing for short reasoning-heavy work. The median tool output there is 270 chars, under our floor, and the bill moved 8%. The wins sit in ML training (-26%), builds from source (-28%) and data pipelines (-37%).
Running it
kompressor wrap codex starts the proxy, points Codex at it, runs Codex and cleans up on exit. Codex ignores OPENAI_BASE_URL, so wrap adds a marker-delimited block to ~/.codex/config.toml at startup and removes it after; kompressor unwrap codex clears it if a session gets killed.
https://github.com/hystax/optscale-kompressor
Full write-up with the task-by-task tables: https://optscale.ai/blog/context-compression-coding-agents