Repository navigation
Open
Labels
Description
We benchmarked RTK against 41 shell commands across 5 repos (4 Go, 1 JS) using Claude Sonnet 4.6 and Opus 4.6. The methodology target is ≥40% average compression, but actual results show mean cost savings of +0.2% (Sonnet) and +2.7% (Opus) — essentially noise.
Only 7 of 41 commands exceeded 5% savings. 34 of 41 commands fell within ±2%.
Environment
- RTK version: brew install rtk-ai/tap/rtk (latest as of 2026-05-17)
- Agent: Claude Code SDK (Sonnet 4.6 / Opus 4.6)
- Repos: Go monorepos + 1 JS repo
- Commands: go test, go build, go vet, make *, git *, pnpm *
What we expected
RTK compresses command output before it enters the agent context. For verbose commands (go test -v, go test -race, lint output), we expected significant token reduction in cache_creation_input_tokens.
Key data points
Where RTK works (>5% savings):
- go test -race ./... — 10-18% savings (race detector output is highly compressible)
- go test -tags=ut -race ./... — 8-14% savings
- go test -v ./internal/usecases/agents/... — 5-7% savings (verbose flag = more output)
- go vet ./... on genaihub — 6-12% savings (large codebase = many findings)
Where RTK does nothing or hurts (±2%):
- All git commands — output is already terse
- All go build / make build — success output is minimal
- go list ./... — package names are already compact tokens
- pnpm install / pnpm run test — output is short
- make test (wrapped targets) — Makefile absorbs verbose output
Questions
- Is RTK doing anything for short output? When cache_write baseline is ~5,300 tokens, RTK shows 0% delta. Is there a minimum output threshold below which RTK should bypass compression entirely to avoid overhead?
- Compression strategy for Go test output: The only consistent wins are commands with -race or -v. Standard go test ./... (PASS/FAIL summary only) gets no benefit. Is RTK's compression tuned for verbose/repetitive patterns specifically, or should it also be summarizing structured output?
- Cache write token counts are nearly identical between baseline and RTK for most commands.
Example: git status baseline=9,542 cache_write vs RTK=9,523 cache_write. The difference is just the response text variation, not actual compression. Is RTK actually intercepting and compressing these commands, or is it passing through when output is below some threshold? - What output volume (tokens) does RTK need before compression becomes effective? Our data suggests the breakeven is somewhere around 1,000+ raw output tokens. Below that, RTK is neutral-to-negative.
Reacted by xiaoas
Activity
bejminliou commentedon May 20, 2026
Hi,
Please provide a minimal reproducible example.
vpovarna commentedon May 23, 2026
Hi @bejminliou
I attached the the result of my benchmark.
This is the test steps:
For each command in the dataset:
Group by repo — commands are grouped by their source repo so each repo is cloned once.
Clone — the repo is cloned via SSH into a temporary directory. The clone is deleted after all commands for that repo have run.
Run in parallel — baseline and RTK run simultaneously using two independent agent sessions:
go test ./...)rtk(e.g.rtk go test ./...), which pipes output through RTK's compression before returning itCollect results — token counts, cost, duration, and success are captured from both agent sessions and written to the results CSV.
bejminliou commentedon May 23, 2026
Hi,
Thanks for the benchmark data, but this is a summary of the results rather than a reproducible example. To test the compression logic, I need the actual text being compressed. Either a link to a public repo where running these commands replicates the ~2% compression ratio or a text file containing the pre-compression stdout/stderr output for one of the failing commands (e.g. go build ./...) will do.
That being said, this seems to be more of an architectural oversight than a bug. We likely need to implement a bypass threshold, and having your raw output will help to determine where that breakeven point should be.
vpovarna commentedon May 24, 2026
@bejminliou
This is the bash script:
go_test_-v______.txt (226KB, 2511 lines) — this is where RTK should compress hard. Verbose test output with repetitive patterns (=== RUN, --- PASS, package paths repeated). Your benchmark showed only 5-7% savings here. The maintainer can run this through the compression pipeline and see why.
This is an internal repo I can't share the logs. But I can run it on open source repo to try to replicate if this is needed.
pszymkowiak commentedon May 27, 2026
🔍 Automated Triage
bugmediumSummary
Systematic benchmark shows RTK achieves ~2% average compression vs. documented ~40% target; likely correct for terse commands but documentation overstates expected gains — needs investigation into threshold behavior and accuracy of the 40% claim.
Triaged automatically by wshm · This is an automated analysis, not a human review.
Yohjisakamoto commentedon Jul 22, 2026
This measured 2% compression result reinforces why end-to-end agent outcomes matter more than compressed text alone: DeepSWE found Tura cuts coding-agent rounds by 89% and total token cost by 80%; would you evaluate the methodology? https://turaai.net/docs#benchmark-current-test-set-record
HetCreep commentedon Aug 4, 2026
Some source-side findings that may be useful here, from an external audit of v0.44.2 (
700bdde). I have not reproduced @vpovarna's benchmark, so nothing below explains their end-to-end token numbers — I am adding things that are checkable in the tree and that bear on this thread.Provenance: AI-assisted source audit, human-directed. Items marked MEASURED were run on this machine; the rest are read from source.
1. The savings figure rtk reports about itself is not always measured against the user's command
Two places compute the "before" side from something other than what the user ran:
src/cmds/system/search.rs:719passesraw_outputas the baseline. That is the output of rtk's own invocation (grep -n -H -I --null …), not theplainbaseline that the same function builds at:620. Because-H --nullemits the file path on every match line, the reported savings percentage moves with the length of the path you searched — same content, deeper directory, different number.src/cmds/system/ls.rs:53,88runsls -laand records the baseline as-la {target}even when the user typed plainls.This matters for this issue in a specific way: any comparison between "documented 40%" and observed results is comparing two different denominators, so the two numbers were never on the same footing to begin with.
2. The savings floor is written down twice, with different values, and neither one gates anything
.claude/rules/cli-testing.md:124calls ≥60% "the release blocker".CONTRIBUTING.md:268states the floor as ">=20%".scripts/benchmark.sh:693-694printsWARNING: …% good (target 60%)without touchingEXIT_CODE. Only negative savings and empty output actually fail the script.So a broad compression regression would not stop a release, and would not turn a check red. That seems worth knowing in a thread about compression being far below target — it is the mechanism by which such a drift can persist unnoticed. There is a related shape in
src/cmds/system/pipe_cmd.rs:574,595, where two filters ship withsavings >= 40.0and a// TODO: grep pipe filter below 60% target.3. Some of the exact commands in this benchmark take a path with no output cap
The dataset here is
go test,go build,go vet,make *,git *,pnpm *.makeis one of the 63 builtin TOML filters, and that generic path (src/main.rs:1330,1337,1351) uses a bare.output()— the 10 MiBRAW_CAPatsrc/core/stream.rs:245guardsrun_streamingonly and is bypassed here — then makes several more full copies (toml_filter.rs:512builds aVec<String>per line,:541rejoins it).4. MEASURED:
rtk grepcosts far more resources than the command it replacesNot a compression-ratio point, but it is the cost side of the same ledger, and it was measured rather than reasoned:
grep(20 MB input)rtk grep(same job)Peak memory scales linearly at roughly 12× the input (5 MB → 69.8 MiB, 20 MB → 246.9 MiB, 40 MB → 481.4 MiB) — to emit 2,579 bytes of output. The cause is in
src/cmds/system/search.rs:565-630,682: the uncappedexec_captureresult is copied about four times (raw_output = result.stdout.clone()at:568, aHashMapholding one ownedStringper match at:595-605, a full re-render intoplainat:621-630, thenmatch_blockper file), and:641-645adds a fifth by accumulating the full text of every file past the display cap.max_resultscaps the display, never the intake.What I would suggest checking first
If the goal is to explain the benchmark, item 1 is the one I would test first, because it means rtk's self-reported savings and an external token count are measuring different things — and any tuning done against the internal number would be tuning against a moving target. Items 2–4 are separate and stand on their own.
Happy to provide the exact repro steps for the memory measurement, or to be corrected on any of this.