Skip to content

About

Benchmark CLI: do token-saving tools for coding agents actually cut cost per solved task? Same tasks with/without each tool, cost split by token type, bootstrap CIs, no-op control.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

33 Commits

Folders and files

Repository files navigation

TokenTrial

Does your token-saving tool actually save money?

TokenTrial is an open benchmark for the token-saving tools that coding agents use, such as RTK, caveman, headroom, context-mode and CLAUDE.md variants. It runs the same coding tasks with and without each tool and reports the number that matters: dollars per correctly solved task.

v0.3 results (2026-11-13, 1,188 runs, Haiku 5.5 and Sonnet 5.5, 18 tasks):

  • No tool saved money beyond the noise floor on either model.
  • caveman v4.1.0 made Sonnet runs 25% more expensive (95% CI +12% to +44%) than its control: its instructions add about 1,850 tokens to every session, and Sonnet's output didn't get shorter. On Haiku it was −8% (CI −19% to +5%).
  • rtk's v0.2 penalty replicated on the Bash-heavy tasks where it does the most work: +38% for v1.1.0 on Haiku and +36% for v1.2.0 on Sonnet. Averaged over all 18 tasks it was +4–5% (inconclusive).
  • headroom 0.42.0 had no measurable effect against a pass-through proxy (−6% Haiku, −2% Sonnet).

Leaderboard: https://bishtashish708.github.io/tokentrial/ · Details: results/v0.3/FINDINGS.md · v0.2 (rtk +36%, caveman ±0%, 400 runs) · pilot.

Try it on your own Claude Code subscription (needs uv; a 72-run Haiku check of rtk and caveman against baseline and a do-nothing arm, about $0.70 API-equivalent):

git clone https://github.com/bishtashish708/tokentrial && cd tokentrial && uv sync && uv run tokentrial install-arms && uv run tokentrial run --repeats 1 --out runs/mine && uv run tokentrial report --runs runs/mine

Only the pinned tool versions listed in results/v0.3/FINDINGS.md have been tested. Tool authors: if an arm is set up wrong, open an issue and it will be rerun and published either way.

Status: alpha. The runner, the arms, verified prices and report work. v0.1, v0.2 and v0.3 have run. A static leaderboard is generated from the results/*/summary.json files by scripts/make_site.py into docs/. See docs/PLAN.md.

Why

Token-saving tools publish large savings figures, usually counted on the tokens they compress. But an agent's bill is made of four token types with very different prices:

Token type Typical price relative to fresh input
Fresh input 1x
Cache write about 1.25x (5 min) or 2x (1 h)
Cache read about 0.05x to 0.1x
Output about 5x

A tool can cut 90% of the tokens it touches and still not lower the bill. That happens if those tokens were cheap cache reads, if the tool breaks the prompt cache, or if the agent needs more turns or fails more tasks. Quesma's analysis of RTK is one example: it questioned whether a headline saving of 89% turned into a lower total cost. TokenTrial makes this kind of check repeatable, public, and applicable to any tool.

Methodology

  1. Tasks with checkable answers. Each task is a small repo plus a hidden check script (tests or an exact output). A run is "solved" only if the check passes. Agents don't grade themselves.
  2. Arms.
    • baseline: the unmodified agent.
    • noop: a control arm. It goes through the same install and wiring steps as a tool but changes nothing. Any difference between noop and baseline is noise.
    • noop-hook and headroom-passthrough: matched controls that reproduce a tool's side effects on Claude Code (a SessionStart hook, a local proxy) without the tool itself.
    • One arm per tool, installed at a pinned version with its documented setup.
  3. Same conditions. Same model, agent version, prompt, task snapshot and limits for every arm. Arms run interleaved, not in blocks, so API-side drift affects them all equally. Each (task, arm) pair runs N times (default 3).
  4. Full token accounting. Usage is taken from API responses for every call in a run and split into fresh input, cache write (5 min / 1 h), cache read and output. It's then priced from a versioned table (pricing.toml) for Anthropic and Amazon Bedrock.
  5. Headline metric. total cost of all runs / number of solved runs, per arm. Also reported: solve rate, cost per run, turns per run, and the cost split by token type.
  6. Uncertainty. 95% confidence intervals from a bootstrap that resamples tasks, then runs within each task. Differences are reported against baseline, with the noop gap shown next to them. A tool counts as "saving money" only if its interval clears both.
  7. Reproducibility. Raw usage records, the tool versions, the price table and the code commit are published with every leaderboard entry.

Usage

TokenTrial runs on your Claude Code subscription by default. No API key is needed. It drives claude --print --output-format stream-json headlessly, records token usage for every API call, and prices that usage at API rates. This gives an API-equivalent cost for each run.

uv sync
uv run tokentrial doctor                          # checks claude is installed and logged in (no model call)
uv run tokentrial run --dry-run                   # show the planned run matrix
uv run tokentrial run --arm baseline --arm noop   # run on the subscription
uv run tokentrial run --resume --out runs/pilot   # continue after a usage limit
uv run tokentrial run --mode api                  # optional: bill ANTHROPIC_API_KEY instead
uv run tokentrial report --runs runs/pilot       # cost per solved task with bootstrap CIs

Defaults are set for a low-cost run: Claude Haiku 5.5, 18 tasks, the baseline, noop, rtk and caveman arms, 3 repeats, and caps of $30 total and $1 per run (API-equivalent). Subscription usage limits make runs slower. When one is hit, TokenTrial saves progress, prints when to come back, and exits with code 3. --resume continues without repeating finished runs.

Install the pinned tool arms once with uv run tokentrial install-arms. Then uv run tokentrial report --runs runs/<exp> --export-raw writes summary.md, summary.json and scrubbed raw data to results/<exp>/.

Leaderboard

Published on GitHub Pages from docs/: https://bishtashish708.github.io/tokentrial/. Regenerate it with uv run python scripts/make_site.py docs/index.html results/<featured-exp> [results/<more> ...].

Roadmap

  • v0.1 pilot (2 weeks, on a Claude Code subscription): 5 tasks × 4 arms (baseline, noop, rtk, caveman) × 3 repeats, so 60 runs on Claude Haiku 5.5. API-equivalent cost, budget caps, --resume across usage limits, bootstrap CIs, and a static leaderboard. See docs/PLAN.md.
  • v0.2 (done): 10 tasks, including 5 with large pytest and git output, × 5 arms (adding a noop-hook control) × 8 repeats = 400 runs on a subscription, with verified prices.
  • v0.3 (done): 18 tasks across Python, Node, C, SQL and bash; rtk v1.2.0 and caveman v4.1.0 next to the v0.2 pins; headroom with a pass-through control; Haiku 5.5 (810 runs) and Sonnet 5.5 (378 runs). See results/v0.3/FINDINGS.md.
  • Next: pin the agent version (no auto-updates mid-run), larger tasks where compression tools have more to work with, and per-task reporting of where each tool acts.
  • Later: more tools (context-mode, CLAUDE.md variants), more agents and models, effort-level sweeps, and a template so tool authors can submit their own arm.
  • Later: a CI job that reruns the leaderboard when a tool releases a new version, and cost-versus-latency plots.

Contributing

Issues and task proposals are welcome. A good task is small, takes a few minutes for an agent, and has a check that can't pass by accident.

License

MIT

About

Benchmark CLI: do token-saving tools for coding agents actually cut cost per solved task? Same tasks with/without each tool, cost split by token type, bootstrap CIs, no-op control.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages