Local compaction proxy for AI coding agents. Sits between your agent and the API, compacts verbose tool outputs before they reach the LLM. Saves up to ~80% of tokens on grep/ls/git log output — no changes to your agent required.
Works with Claude Code (Anthropic Messages API) and Codex CLI (OpenAI Responses API). Any client that talks one of those two protocols should work.
First, install the binary — see Install (one
tar -xzf+mv).
# Terminal 1 — start the proxy
openchpok --port 8080
# Terminal 2 — point your agent at it, then run claude / codex
eval "$(openchpok env)"
claude "list files in this repo" # or: codex "..."- Open
http://localhost:8080/ui— you should see your request appear, with "chars saved". - Check the JSONL log:
tail -f ~/.cache/openchpok/proxy.jsonl. - No requests showing up? → Troubleshooting.
$ openchpok env
export ANTHROPIC_BASE_URL=http://127.0.0.1:8080
export OPENAI_BASE_URL=http://127.0.0.1:8080/v1
$ eval "$(openchpok env)" # runs those two exports in your current shell
$ # now claude / codex go through the proxy — nothing in ~/.codex/config.toml
$ # or your shell rc is changed permanently- ✅ Claude Code — zero config, uses
ANTHROPIC_BASE_URL - ✅ Codex CLI — zero config, uses
OPENAI_BASE_URL(subscription auth via~/.codex/auth.jsonis picked up automatically) - ✅ Any client speaking Anthropic Messages or OpenAI Responses/Chat Completions
Your agent pastes the full output of grep, ls -la, git status, find into the next LLM turn — every time. Most of that is noise the model doesn't need. openChpok trims it on the way out.
- 💰 Cut token spend — verbose tool results shrink 35–80% before hitting the LLM
- 🚀 Zero agent changes — just point
ANTHROPIC_BASE_URL/OPENAI_BASE_URLat the proxy - 🔍 Full visibility — per-request stats at
/ui, JSONL log at~/.cache/openchpok/proxy.jsonl - 🔒 Local-only — stdlib-only Go binary, no external deps, no telemetry
- 🔑 Reuses your auth — Anthropic API key, OpenAI API key, or ChatGPT subscription via
codex login
Agent (Claude Code / Codex / ...)
│
│ ANTHROPIC_BASE_URL / OPENAI_BASE_URL=http://localhost:8080
▼
┌──────────────────────────────┐
│ openChpok │
│ │
│ Match tool_use → tool_result│
│ Strip Codex envelope │
│ Compact verbose output │
│ Re-attach envelope │
│ Forward to real API │
│ Stream SSE back as-is │
│ Log metrics │
└────────────┬─────────────────┘
▼
api.anthropic.com / api.openai.com
Requests are compacted; responses pass through unmodified. For Codex, the proxy also preserves the stdout envelope (Chunk ID, Wall time, Process exited) while compacting only the useful body.
Savings measured on internal/compact/testdata/*.txt (go test -run TestCompressionBaseline -v ./internal/compact/...). Real-world savings vary by command and repo size.
| Compactor | Trigger | What it does | Saving on fixture |
|---|---|---|---|
| git_status | git status |
keeps section headers + per-file prefixes; drops advisory hints and ahead/behind noise | 35–61% |
| git_log | git log --oneline |
caps at 20 most recent lines, adds overflow marker | ~78% |
| ls | ls -la, ls -R |
-la: drops perms/owner/group/hardlinks/total, keeps raw byte sizes; -R: indent+dash tree |
~78% on -la |
| grep | grep, rg (Bash) |
top-of-output TOC (files by match count), per-file grouping, long-line truncation, hidden (N): footer |
~80% |
| find | find |
indent+dash directory tree, collapses large siblings into ... +K more, hidden (N): footer |
~15% |
More compactors & safety rules
Never compacted: Read/cat file content, Edit/Write tool results, Glob, errors. If a compactor produces output larger than its input, the raw output passes through unchanged.
Additional compactors in internal/compact/: git_diff, git_show, git_branch, git_reflog, git_stash, tree.
Snippets come from real fixtures in internal/compact/testdata/.
# git status (verbose) # openchpok git status (compact)
Your branch is ahead by 3 commits On branch feature/refactor
(use "git push" to publish) Changes to be committed:
Changes not staged for commit: modified: internal/compact/compact_find.go
... ...
# ls -la (full metadata) # openchpok ls -la (compact)
drwxr-xr-x 33 user staff 1056 ... . .claude/
-rw-r--r-- 1 user staff 503 ... .gitignore .gitignore 503
-rw-r--r-- 1 user staff 20488 ... README.md README.md 20488
... 20 files, 10 dirs
# grep -rn foo . (flat stream) # openchpok grep -rn foo . (grouped)
src/a.rs:19: ... 547 matches in 15 files:
src/a.rs:79: ... src/a.rs: 25
src/b.rs:9: ... src/b.rs: 6
... ...
Download openchpok_<version>_<OS>_<arch>.tar.gz (or .zip on Windows) from the releases page, extract, and place the openchpok binary on your $PATH.
# Linux/macOS
tar -xzf openchpok_*.tar.gz
chmod +x openchpok
sudo mv openchpok /usr/local/bin/git clone https://github.com/sady4850/openChpok.git
cd openChpok
go build -o ./bin/openchpok ./cmd/openchpokSettings come from (in order of precedence): CLI flags → JSON config file → built-in defaults. The default config path is $XDG_CONFIG_HOME/openchpok/config.json (falls back to ~/.config/openchpok/config.json). Missing file is fine — defaults apply.
{
"upstream": "https://api.anthropic.com",
"port": 8080,
"verbose": false,
"dump_dir": ""
}- CLI flags:
openchpok --help - Env exports helper:
openchpok env --help - Debug dumps:
--dump-compacted <dir>writes.orig.txt,.comp.txt,.meta.jsonper tool call
Open http://localhost:8080/ui — server-side rendered, auto-refreshes every 10s. Shows total requests, tool calls, chars saved, per-compactor savings, per-tool breakdown, and recent sessions. Same numbers as JSON at /api/stats:
curl -s http://localhost:8080/api/stats | jq '.requests, .tool_results, .total_saving_pct'openchpok: command not found— ensure the install location is on your$PATH.- Port 8080 is busy — run with a different port, e.g.
openchpok --port 18080, and usehttp://localhost:18080/ui. - Dashboard shows zero requests (Codex) — you may have hit openai/codex#16719: some codex CLI releases silently ignore
OPENAI_BASE_URLandopenai_base_urlinconfig.toml. Fix: upgrade codex. - Dashboard shows zero requests (Claude) — confirm the agent terminal has
ANTHROPIC_BASE_URLpointing at the proxy. - Auth errors (401/403):
- Codex subscription: run
codex loginto populate~/.codex/auth.json - Codex API-key: ensure
OPENAI_API_KEYis set in the agent's terminal - Claude: ensure your Anthropic credentials are set for
claude
- Codex subscription: run
- Telemetry/log file — local-only JSONL at
~/.cache/openchpok/proxy.jsonl; reset withrm ~/.cache/openchpok/proxy.jsonl.
- Go 1.25+
- Zero external dependencies — stdlib only
