- 版本
- 2.6.0
- 发布日期
- 2026-11-25
- 平台
- Windows
- 安装包大小
- Windows 9.8 MB
- 发布者
- hystax
optscale-kompressor
Deterministic prompt compression for coding agents, in one Rust binary.
README
OptScale Kompressor
Deterministic prompt compression for coding agents, in one Rust binary.
OptScale Kompressor sits between a coding agent and its model provider. It removes the repetitive tool output agents re-send on every turn, and on Claude Code it keeps the provider's prompt cache alive while tools run.
Install it (Linux and macOS; other platforms):
curl -fsSL https://raw.githubusercontent.com/hystax/optscale-kompressor/main/install.sh | sh
Then run your agent through it:
kompressor wrap codex
That starts the proxy, points Codex at it, runs Codex, and cleans up on exit.
wrap also knows claude, opencode and aider. When the session ends it
tells you what happened:
kompressor: 26 request(s), 126 message(s) compressed, ~2029706 tokens saved (2015180 net of retrieval)
Measured on Terminal-Bench 2.1, as the difference between real provider bills:
| Agent | Bill vs no compression | Tasks solved | What does it |
|---|---|---|---|
| Codex on GPT-5.5 | −22.7%, about twice Headroom's savings | 81.1% vs 82.2% | Cache-safe compression of tool output |
| Claude Code on Opus 5.5 | −20%, with 99% fewer tokens lost to cache expiry | 90.6% vs 89.9% | Keeping the prompt cache alive |
Results · Reading the savings honestly · Not built yet
Install
curl -fsSL https://raw.githubusercontent.com/hystax/optscale-kompressor/main/install.sh | sh
No Rust toolchain needed. install.sh downloads the latest
release's binary or package, checks it against the release's SHA256SUMS, and
stops on a mismatch:
- Linux x86_64 and arm64: the binary goes to
~/.local/bin. No root. On x86_64 it is the glibc build where that runs, and the static one otherwise; the arm64 build needs glibc 2.28 or newer. A build that does not start is never installed, so an existingkompressoris left in place. The packaged configuration is written to~/.config/kompressor/config.tomlunless one is already there; it is fetched from the repository at the release tag rather than from the release's assets. - macOS (Apple silicon and Intel): the universal
.pkgis installed withsudo installer: the binary in/usr/local/bin, a user config, and a LaunchAgent that serves the proxy. Details: docs/MACOS.md.
KOMPRESSOR_VERSION=2.6.0 pins a release, KOMPRESSOR_INSTALL_DIR moves the
Linux binary, and KOMPRESSOR_LIBC=musl (or gnu) picks the x86_64 build. Then check it runs:
kompressor version
Packages
To install a system package instead, or on another platform, download it from
the latest release
and check it against SHA256SUMS from the same page
(sha256sum --check --ignore-missing SHA256SUMS).
| Platform | File | Install |
|---|---|---|
| Debian, Ubuntu | kompressor_<version>-1_amd64.deb |
sudo apt install ./kompressor_*-1_amd64.deb |
| RHEL, Fedora | kompressor-<version>-1.x86_64.rpm |
sudo dnf install ./kompressor-*-1.x86_64.rpm |
| Any Linux x86_64 | kompressor-<version>-x86_64-linux-musl (static) |
install -m 755 kompressor-*-x86_64-linux-musl ~/.local/bin/kompressor |
| Debian, Ubuntu on arm64 | kompressor_<version>-1_arm64.deb |
sudo apt install ./kompressor_*-1_arm64.deb |
| RHEL, Fedora on aarch64 | kompressor-<version>-1.aarch64.rpm |
sudo dnf install ./kompressor-*-1.aarch64.rpm |
| Any Linux arm64, glibc 2.28+ | kompressor-<version>-aarch64-linux-gnu |
install -m 755 kompressor-*-aarch64-linux-gnu ~/.local/bin/kompressor |
| macOS (Apple silicon and Intel) | kompressor-<version>-universal2.pkg |
sudo installer -pkg kompressor-*-universal2.pkg -target / |
| Windows x86_64 | kompressor-<version>-x86_64-setup.exe |
run it; see docs/WINDOWS.md |
| FreeBSD x86_64 | kompressor-<version>-x86_64-freebsd.pkg |
sudo pkg add ./kompressor-*-x86_64-freebsd.pkg |
Older glibc systems can use the -static .deb / .rpm builds instead. With
the GitHub CLI the download is one command, for
example:
gh release download --repo hystax/optscale-kompressor -p 'kompressor_*-1_amd64.deb' -p SHA256SUMS
docs/QUICKSTART.md covers running it as a service, and docs/WINDOWS.md the Windows paths, including Claude Desktop and the Codex app.
From source
With Cargo (Rust 1.95 or newer):
cargo install --locked --git https://github.com/hystax/optscale-kompressor kompressor-cli
Or from a checkout:
git clone https://github.com/hystax/optscale-kompressor
cd optscale-kompressor
make release
./target/release/kompressor version
make deb, make rpm, make static (musl), make linux-arm64-all,
make docker, make macos-pkg-docker, make win and make win-installer
build packages; each
says what it needs if a tool is missing.
Quick start
Codex
kompressor wrap codex
Codex ignores OPENAI_BASE_URL (measured on 0.155.1), so wrap adds a
marker-delimited block to ~/.codex/config.toml at startup and removes it on exit,
leaving everything else in the file byte for byte. It reads Codex's own
auth.json and writes the block that matches your login, API key or ChatGPT plan.
If a session is killed, kompressor unwrap codex removes the leftover block.
Details: docs/CODEX.md.
A subscription session opens a WebSocket, which the proxy relays and compresses —
on by default. Relayed turns report no provider usage, so their
savings are real but unmeasured; KOMPRESSOR__PROXY__WEBSOCKET_RELAY=false trades
that coverage back for the numbers.
With an API key, the proxy can also ask OpenAI to keep each prompt's cache for a
day rather than minutes. It is free to write on gpt-5.5 and earlier, added only
on api.openai.com for the models OpenAI documents it for, and dropped again if
the upstream refuses it. Off by default; on archived Codex runs the expiry it
prevents was about 0.35% of the bill
(DESIGN.md §12.10):
[proxy.providers.openai]
prompt_cache_retention = "24h"
opencode — the TUI and OpenCode Desktop
kompressor wrap opencode # a TUI or `run` session of its own
kompressor wrap opencode --attach # Desktop, and every session on the background service
opencode 2.x is pointed at the proxy through its own configuration, never a
variable: OPENAI_BASE_URL in its environment makes every OpenAI model
"unavailable" (measured on 2.2.4). A launched session gets the overlay in
OPENCODE_CONFIG_CONTENT and runs --standalone, because the shared background
service that otherwise makes the model calls never sees our environment.
Desktop uses that service, so --attach writes the overlay into the global
opencode.json, runs opencode reload, and puts the file back on exit. Both
route the built-in openai, anthropic, OpenCode Zen and OpenCode Go
providers, and leave alone any provider whose baseURL you set yourself.
OpenCode Desktop needs 2.2.4 or newer: the CLI that 2.0.11 bundles does not
reliably honour a provider's baseURL, so its traffic bypasses the proxy.
Details, including a permanent setup: docs/OPENCODE.md.
Other agents
kompressor wrap --list # the agents wrap knows
kompressor wrap aider -- --model sonnet # your own arguments go after --
kompressor wrap --env NAME=root|v1 -- your-agent
wrap knows codex, claude, opencode, aider, cursor (prints the base URL
to set in Cursor's settings; only applies when Cursor uses your own OpenAI key) and
cursor-agent (refused with an explanation: it speaks Connect RPC over protobuf,
which the proxy cannot read).
Claude Code
kompressor wrap claude
wrap claude uses a kompressor already serving on its port, such as the
installed service, and otherwise starts one with the first config it finds:
$KOMPRESSOR_CONFIG, ./kompressor.toml, then
~/.config/kompressor/config.toml. The Anthropic profile comes from that config,
not from the command. The packaged configuration (/etc/kompressor/config.toml
on Linux, ~/.config/kompressor/config.toml on macOS) turns on tail-only
compression and the adaptive one-hour TTL under [proxy.providers.anthropic].
Keep-warm is on by default for Anthropic traffic. It is the one thing the
proxy sends that no client asked for, so to turn it off:
[proxy.providers.anthropic]
cache_keep_warm = false
With no config file at all, Claude Code traffic runs on the deployment defaults, which freeze the whole conversation Claude Code marks and forward it nearly untouched. The full profile, set by environment for one session:
export KOMPRESSOR__PROXY__PROVIDERS__ANTHROPIC__RETRIEVE_TOOL=always
export KOMPRESSOR__PROXY__PROVIDERS__ANTHROPIC__FROZEN_PREFIX=first_seen
export KOMPRESSOR__PROXY__PROVIDERS__ANTHROPIC__CACHE_TTL=adaptive
export KOMPRESSOR__PROXY__PROVIDERS__ANTHROPIC__ENGINE__ENABLE_CODE_AWARE=false
export KOMPRESSOR__PROXY__PROVIDERS__ANTHROPIC__ENGINE__MIN_ELISION_SAVING_CHARS=4000
kompressor wrap claude
What Kompressor changes on Claude Code, and why: On Claude Code, the cache is the bill. Measured effect: Claude Code on Opus 5.5.
wrap claude also hands Claude Code the retrieve tools as an MCP server it
launches itself, so a ref:k_… handle resolves anywhere in the session rather
than only while a request is passing through the proxy. Nothing durable is
written — no ~/.claude.json, no ~/.claude/settings.json — so there is no
unwrap step. Measurements and the full argument:
docs/CLAUDE-CODE.md.
Claude Desktop — intercepted, because it cannot be pointed
Desktop's Code tab is Claude Code, and it cannot be wrapped: the app sets
ANTHROPIC_BASE_URL itself when it spawns a session, over the inherited
environment and over ~/.claude/settings.json alike. There is no value to set.
What it does honour is a proxy and a certificate authority, so that is the way in:
[proxy.intercept]
listen = "127.0.0.1:8840"
intercept_hosts = ["api.anthropic.com"]
ca_path = "/home/you/.local/share/kompressor/ca"
alpn = ["h2", "http/1.1"]
CONNECT on that port, TLS terminated for the allow-listed host with a
certificate minted locally, everything else tunnelled byte for byte. The
decrypted request is served by the same router the proxy already runs, so no
mount or handler changes to support it. The Code tab's traffic is Anthropic
Messages like the CLI's, so the [proxy.providers.anthropic] profile described
above applies to it unchanged. Point Desktop at it with HTTPS_PROXY
and NODE_EXTRA_CA_CERTS in ~/.claude/settings.json.
The packaged default enables it, so a clean install listens on 8840 and
generates its CA on first start. Nothing trusts that CA until you install it,
and a client that has not been pointed at the proxy is unaffected either way.
Comment out listen to turn the listener off — it is off unless an address is
named, so an upgrade of a machine that never had it stays that way.
This covers the Code tab. The Chat tab reaches claude.ai with a web
session and its own conversation API — nothing a reverse proxy can serve, and
nothing worth serving: its history is held server-side, so a turn carries one
message and an id. Setup, mea