AI Coding Agents
What Tokbench Measured About Token-Saving Middleware
Tokbench is an independent benchmark of token-saving tools for coding agents. In its pilot, with N=1 per arm, RTK, both lean-ctx configurations, and Headroom logged more provider-billed input than the native run. The authors attribute RTK’s gap to run-path variance and describe Headroom’s total as within the pilot’s noise.
What the experiment held constant
The tokbench pilot, with N=1 per arm, asked each configuration to fix a real defect in cartographer, a small TypeScript CLI. The defect involved a dynamic import with await inside a synchronous save function. The coding agent had to keep saving synchronous, fix the first-write path, and pass the repository’s regression and quality checks. The task went through planning, reviews, implementation, validation, approval, commit, and writeback. That scope lets the comparison include calls after the code change, where an agent can still do a lot of work. tokbench pilot README
Each arm started from a checksummed reset and used the same forge-cli harness on pi, with ollama-cloud as the provider and the same persona-to-model map across the GLM model tiers. The operator followed a scripted observe-only protocol. All pilot arms passed the engagement check for their configuration and finished with the quality gates green. Passing the engagement check means the expected integration took part in the run. It gives you a reason to compare the arms, while adoption and payload coverage still need to be measured.
The native harness was designed to keep context lean. Each phase began with its own agent context, with reviewed artifacts carrying work forward. Store and artifact operations used compact harness-owned tools. A shell command filter or tool runtime would only affect the traffic it reached. The authors disclose that the harness and test project are their own products and that the author uses lean-ctx. Their findings describe that setup, its interactive operation, and its request-metered provider without prompt-cache discounts.
Provider-billed input and model latency
The following figures come from the tokbench pilot with N=1 per arm. The latency column is seconds of model time per request turn. It cannot tell you how long an end user waited for the full task, including local work and review gates. tokbench pilot results
| Pilot configuration | Interception in this setup | Provider-billed input | Change from native | Model seconds per turn |
|---|---|---|---|---|
| Native | Existing harness only | 2.28M | Baseline | 2.8 |
| RTK 0.42 | Command rewrite | 2.89M | +27% | 4.2 |
| lean-ctx 3.7 with embedded MCP | Context tools and connected bridge | 3.14M | +38% | 4.2 |
| Headroom 0.23 | HTTP proxy on the provider request path | 3.24M | +43% | 3.7 |
| lean-ctx 3.7 default | Context tools with the default integration | 3.62M | +59% | 6.8 |
An optimizer has to compete with the way your agent already works. A workflow that hands off a compact plan between isolated phases may have much less repeat history than a session that carries all of its turns forward. A workflow full of compiler output may send a larger fraction of its input through a shell filter. The numbers describe the task that ran, with the versions and integrations used in the pilot.
These are provider-reported input counts. They leave out the rate required to turn token usage into dollars and do not include output charges. On a provider with discounted cache reads, changes to the cache buckets could affect the price even when total input moves in the same direction. Use a bucketed ledger for that trial. Context compression versus prompt caching
The three meters answer different questions
Tokbench’s pilot, with N=1 per arm, juxtaposes project claims, product counters, and provider usage. For each number, ask what was counted and what the percentage divides by. Label the request or task boundary as well. tokbench’s three-meter comparison
| Meter | Question it can answer | What a buyer should inspect |
|---|---|---|
| Project benchmark claim | How much did the project report removing under its conditions? | Payload type, workload, comparison baseline, and denominator |
| Product counter | How much did the tool report changing in the tested run? | Which calls reached it, what passed through, and whether the counter includes injected overhead |
| Provider usage | How much input did the provider meter over the calls the agent made? | All task phases, output, actual billing categories, and whether the task passed |
For RTK, tokbench quotes a project claim of 60% to 90% savings. In the pilot run, RTK’s meter reports 58.4K saved and 74.7% savings on commands it touched. Those reported savings amount to about 2.5% of native billed input. Work done through native reads, tool schemas, harness-managed state, and messages from earlier turns still contributes to billed input.
Tokbench’s notes put the reported savings below the pilot’s noise floor and attribute the RTK arm’s 27% higher billed input to run-path variance.
For Headroom, the benchmark reports 342K tokens removed on the wire. Its within-run ledger reconciled to provider input within 0.0004%, and untouched requests calibrated the comparison. That validates the difference between transformed and untransformed payloads on the observed request path. The Headroom arm took 237 turns against native’s 180. A comparison against the original payloads on those 237 turns cannot establish how many turns the agent would have taken with the proxy disabled. The cross-arm totals describe separate executions.
For lean-ctx, the pilot notes show why connection and adoption both need their own checks. The default pi integration ran through one-shot CLI processes with the persistent bridge off. In the connected MCP arm, the harvested gain report showed zero tokens saved. The experiment observed additional tool definitions, partial use of the context tools, and expensive late phases. Similar turn counts in the connected and native runs still produced different billed input. Inspect tool definitions and the amount of context each turn carries along with the number of turns. Pilot run notes
What a single run per arm can establish
A trace can establish that a particular command was rewritten, that a provider request got shorter, or that an integration started with the bridge connected. The averages in the pilot table describe observed executions. With N=1 per arm in the tokbench pilot, the table cannot separate normal run-to-run variation from an effect of the middleware on the amount of work the agent did. Even the native path can take different turns through the same task.
Phase totals make this problem visible. A run might spend little time implementing a small patch and then generate repeated calls in commit or writeback. If one arm happened to take a longer path in those phases, its input total includes the repeated context across that path. If configuration changes introduce new tool instructions, those can raise prompt size on every request even when the model rarely uses the tools. Inspecting the per-phase transcript can show which of those patterns occurred. Repeating the comparison helps assess whether the pattern recurs.
The captured README’s line about Headroom’s total being within noise should be read alongside the table showing higher billed input in that particular pilot run. The observed difference is clear. The uncertainty is whether a direction and magnitude persist across reruns. The evidence also contains a follow-up protocol and analytics notes. The protocol interleaves repeats and defines engagement, exclusions, and acceptance gates. Its amended lean-ctx configuration differs from the pilot. Keep the follow-up records tied to their run classes and version pins when reading them. Pre-registered tokbench protocol
Reconstruct what each arm actually changed
The pilot’s engagement checks are useful because an inactive integration can look like a fast treatment. A command filter should leave a record of a rewrite. A request proxy should show a transformed request. A tool-level integration should show that the model had access to the alternate tools and selected them for relevant work. Recurring overhead can persist even when active use is low, so record engagement and frequency separately.
The lean-ctx notes give a specific example of the difference between infrastructure and usage. The benchmarkers found expensive phases where the model still leaned on native operations. They also describe a follow-up shakedown where reads reached the bridge but repeated reads crossed phase boundaries. Each phase’s new bridge started cold. The exact bridge behavior is version-specific, and the broader trial question is whether your repeats occur inside the lifetime of the store that can serve them. tokbench integration notes
The benchmark’s protocol also distinguishes a quality-gated input comparison from runs excluded because the infrastructure or treatment did not engage. Use that distinction when reading any tool evaluation. If a dashboard tracks only completed work, it can omit spend a buyer still pays on failed attempts. Ask for the success rate and the handling of voids, timeouts, and retries alongside the headline usage figure. A local rollout decision should count operational failures in its own spend ledger.
For a proxy, request-by-request reconciliation tells you more than a session-total comparison about the compression itself. For a command tool, preserve the original and transformed output so you can verify that the remaining text retains the detail the task checks. For a tool catalog, inspect the request before any tool selection so you can see overhead even on a turn where the agent uses no alternate tools. These checks turn the published observations into specific measurements you can repeat.
How to use the pilot when buying
For RTK, measure how often the shell path carries expensive text. If your agents mostly use native file reads and structured tools, even good shell filtering will have a small addressable share. Count eligible commands and determine how much input appears in their replies. Check that failures stay diagnosable and that the original output remains available when the agent needs it. A bypass run is an appropriate comparison for a noisy command. The decision still depends on billed usage and accepted work over the whole task. RTK, Headroom, and context-mode comparison
For lean-ctx, verify which tool the agent actually calls and when it can reuse local state. Keeping an additional tool available has a cost if its definition rides in each prompt. A working bridge helps where the model rereads the same material within the relevant cache lifetime. The pilot and integration notes give you concrete checks to do on your installation. Record which reads use the context route, which return a compact reference, and which carry the full payload again. lean-ctx review
For Headroom, verify the provider request and the continuation. A wire ledger can validate that the configured proxy changed the input. The next question is whether answers, retrievals, task success, and cache behavior are consistent with a lower total cost. Check warm and cold runs separately if your provider charges different rates for reused prefixes. Look at actual provider usage before assigning any savings to traffic you believe the proxy intercepted.
Choose tasks from the deployment you plan to use. Repeat a baseline and a treatment from the same starting state, pin versions, and record the runs even when an attempt fails. Report provider-billed input, cache usage where available, output, elapsed time, and pass rate. Compare full-task spending before deciding whether to keep middleware enabled. The pilot’s main purchasing lesson is to ask for results at the same boundary where you pay and judge the work. A/B measurement guide
Sources
- tokbench independent pilot, N=1 per arm (GitHub, accessed 2026-11-30)
- tokbench pilot run notes, N=1 per arm (GitHub, accessed 2026-11-30)
- tokbench pre-registered follow-up protocol (GitHub, accessed 2026-11-30)
Interactive report
- Do Token Savers Actually Save?: RTK reported saving 74.7% of the tokens on the commands it touched. In tokbench’s pilot, the RTK run still used 27% more provider-billed input than the unmodified run. The comparison shows why a tool’s savings counter and the provider’s meter can move in opposite directions.
How this note was produced
Drafted with AI assistance from committed ByteCosts pricing snapshots and deterministic cost formulas. Figures are grounded in the linked sources (last updated 2026-11-30). Read our editorial & automation policy, inspect the methodology, or report a discrepancy.
What Tokbench Measured About Token-Saving Middleware. ByteCosts. Updated 2026-11-30. https://bytecosts.com/blog/tokbench-token-saving-middleware-benchmark/