Cutting the tokens an AI coding agent processes doesn't reliably cut the bill. In a 2026 preprint that hasn't been peer reviewed, a setup the authors built by adding features to the open-source RTK tool cut tool-output tokens reaching the agent by 38.4%, yet raised billed cost by 6.8%1. Prompt-cache writes and reads account for most input-side cost, and compression can change how the agent goes about its work.
That's why a cost change should be judged by what it costs to finish a task successfully, not by how many tokens it removes. I ran token reduction tools for about 3 months, and the reduction rates they reported never told me whether I was burning through my usage limits any more slowly. Below, we'll cover how token reduction reaches your bill, why the bill didn't drop in the study, what the study can't tell you, and how to measure cost per successful task.
- Weinberger and Hozez, "Token Reduction Is Not Cost Reduction: An Empirical Study of End-to-End Efficiency in API-Based Coding Agents" (2026, preprint, not peer reviewed). ↩
What's in this article?
Start with how token savings do or don't reach the bill, then look at the results and at a better way to evaluate cost changes.
- How does token reduction affect your bill?
- Why doesn't cutting tokens always cut the bill?
- What can and can't this study tell you?
- How should you evaluate a cost change?
How does token reduction affect your bill?
Change against unmodified Claude Code, RTK-ML setup
Token reduction only lowers the bill when the tokens you remove make up a large share of what you pay and the agent does the same amount of work. An agent typically calls the model and runs tools many times before it finishes a request. Each round trip is a turn.
Every model call is billed on 4 quantities.
| Quantity | What it covers |
|---|---|
| Input | Tokens sent to the model without the cache |
| Cache writes | Input stored in the cache for reuse by later calls |
| Cache reads | Input read back from the cache |
| Output | Tokens the model generates |
Each quantity has its own price. On Anthropic's pricing page as of September 2026, Claude Sonnet 5 costs $2 per million input tokens, $0.20 for cache reads, $2.50 for 5-minute cache writes, and $10 for output2.
The Claude Code cost documentation explains that Claude Code sends the full conversation with every request and uses prompt caching to re-read that history at the cached rate. Once a tool result lands in the context—everything passed to the model as input—it gets re-read as part of the history on every later turn. Compressing tool output shrinks that turn's input and the cache reads that follow. But a method that compresses only tool output doesn't touch instructions or conversation history.
- Anthropic, "Pricing" (2026; retrieved September 28, 2026). ↩
Why doesn't cutting tokens always cut the bill?
There are 2 reasons. First, compression only reaches part of the bill directly. Second, compression can change how the agent works, prompting extra searches, tests, and turns. The cost of that extra work can outweigh the tokens you saved.
Weinberger and Hozez submitted their paper in July 2026 and revised it to v5 in August; it hasn't been peer reviewed. They ran unmodified Claude Code as a baseline against 3 setups that reduce tool output and context, pairing runs on the same tasks. They measured what the provider actually billed, task success, cache volume, and agent behavior. The main campaign covered 103 tasks with 712 runs per setup1.
The 3 setups work differently. RTK v0.44.1 is the open-source RTK distribution: a hook routes selected shell commands through a proxy that compresses their output before it reaches the model. RTK-ML adds 9 capabilities to RTK, all of which were turned on for the measurements1. The paper labels it a "benchmark build" in Table 2 and an "authors’ branch build" in Appendix A.8. Headroom v0.27.0 is a proxy at the API boundary that, in the paper's words, "interposes on the provider API endpoint via ANTHROPIC_BASE_URL and optimizes payloads in flight." The paper treats it as a black box whose internals the harness can't see; it records the one configuration observed in these campaigns (token-mode optimization on, caching on, code-aware mode off).
| Setup | Change in billed cost (95% CI)1 | Change in success rate (points, 95% CI)1 | Mean turns1 |
|---|---|---|---|
| Baseline (unmodified Claude Code) | — | — (96.2% success) | 4.46 |
| RTK v0.44.1 | -2.7% (-5.6% to -0.1%) | -0.2 (-2.9 to +1.9) | 4.32 |
| RTK-ML | +6.8% (+2.8% to +11.3%) | +0.9 (-0.6 to +2.5) | 4.69 |
| Headroom v0.27.0 | +48.4% (+42.3% to +55.0%) | +1.4 (-0.2 to +3.1) | 4.20 |
- Weinberger and Hozez, "Token Reduction Is Not Cost Reduction: An Empirical Study of End-to-End Efficiency in API-Based Coding Agents" (2026, preprint, not peer reviewed). ↩↩↩
Only RTK v0.44.1 lowered the bill, by 2.7%. The saving is small, and on a frozen holdout of 27 tasks its confidence interval crosses zero, so the paper calls it "suggestive, not holdout-confirmed." RTK-ML cut delivered tool-output tokens by 38.4% and raised billed cost by 6.8%. For every setup, the confidence interval on the success-rate change crosses zero. Across 100 tasks run with RTK-ML on Claude Haiku 4.5, the per-task reduction in tool-output tokens was only weakly correlated with the paired change in billed cost, with a Pearson r of 0.151.
According to the paper, prompt-cache creation and reads dominate input-side cost, which limits what tool-output compression can save directly. Agents that received compressed output were also observed to change course, running additional retrieval, diagnostics, and tests. Section 10.3 of the paper reports that at the first code edit, the median cache-read context was essentially the same for the baseline and the 2 RTK setups (RTK v0.44.1 and RTK-ML), at 25.7k to 25.9k tokens, but 38.7k tokens with Headroom, 49% more1.
Correctness took a hit in places, too. On a separate harness, the authors had Claude Sonnet 4.6 work on 40 Go tasks built from SWE-bench, using a single-shot agent that emits all its edits in one output and can't search again; the paper notes that this isn't a Claude Code measurement. Aggressive compression cut billable tokens by 73% and cost by 59%, but patches that applied cleanly fell from 27 of 40 to 15 of 40. Resolved tasks went from 2 to 11. The paper explains that the compression rewrote or dropped the verbatim anchors that SEARCH/REPLACE edits depend on, and because the study was single-shot, small, and limited to one model, one edit format, and one compression configuration, it cautions against generalizing beyond that setting.
A tool's advertised reduction and your billed cost measure different things. For example, the RTK README says RTK cuts up to 90% of the bash output an agent reads, and adds that this isn't the same as cutting your bill by 90%3. As the README explains, bash output is only one part of the input tokens, and input tokens are only part of the bill.
My own records showed the same gap between what a tool reports and what actually gets counted. On June 19, 2026, I installed 3 token reduction tools at once, including RTK and Headroom, and ran them for about 3 months. By their own counts, the tools cut tokens by 16% to 51%. Yet 95.6% of the tokens counted against my subscription were cache reads, and Headroom's own records showed that its savings made zero contribution to my usage limit. The 16% to 51% figures are the tools' own estimates, not measurements of any effect on a bill or a usage limit.
- Weinberger and Hozez, "Token Reduction Is Not Cost Reduction: An Empirical Study of End-to-End Efficiency in API-Based Coding Agents" (2026, preprint, not peer reviewed). ↩↩↩↩↩
- rtk-ai/rtk README (2026; retrieved September 30, 2026; figure claimed by the tool's maintainers). ↩
What can and can't this study tell you?
The study shows that you can't infer bill savings from token savings. It can't tell you which setup will pay off in your environment. Keep these limitations in mind.
- Not peer reviewed: The paper is a preprint on arXiv and hasn't been peer reviewed.
- Author affiliation: Both authors are affiliated with PointFive. They aren't Headroom's developers, and they built and configured all 3 setups themselves.
- Mostly one agent and version: The main campaign used Claude Code 2.1.201 with Claude Haiku 4.5, Claude Sonnet 5, and Claude Opus 4.81. The paper lists as a limitation that it measured one agent harness (Claude Code) and one provider's billing model, prices, and cache semantics at one point in time. Section 9 adds a replication on Codex CLI that compares only the baseline and Headroom, on 40 paired tasks (80 runs). Both setups passed 39 of 40 tasks, and in the paper's words, "Headroom’s reconstructed cost was 12.49% lower than baseline," the opposite direction from Claude Code, while wall time more than tripled1. Because Codex telemetry doesn't report billed cost, that cost is reconstructed from provider-returned token counts at list prices, not taken from a bill. Headroom reported zero compressed tokens in every run, so the paper describes the saving as an observed proxy, cache, or trajectory effect rather than a demonstrated result of compression. It treats the sign reversal as additional evidence that a layer's effect is a property of the combination of layer, harness, model, and workload.
- Single-prompt benchmark tasks: Tasks came from 6 public repositories (click, cobra, express, flask, gin, and requests) and a synthetic monorepo, averaging 4.46 turns at baseline1. The paper states that all of its end-to-end dollar results come from single-prompt benchmark runs and that generalization beyond Claude Code and the tested workloads isn't established. It treats interactive developer sessions as an unmeasured setting, so the results may not carry over to them.
- High baseline success: Success rates were as high as 96% to 98%, which the paper says limits its sensitivity to small differences, so small performance losses may go undetected1. All runs within a block fell inside the provider's 5-minute cache lifetime, so the paper can't rule out prompt-cache carryover between setups by separating runs in time1.
Research on other compression methods adds context. A preprint on implicit context compression found that learned compression sharply reduced performance on SWE-bench Verified for multi-step software engineering agents. A comparison of prompt compression methods found that higher compression ratios hurt performance on short contexts, while moderate compression sometimes improved it on long contexts. The same study found that every method increased hallucination—output that isn't grounded in fact—mainly because of information loss.
- Weinberger and Hozez, "Token Reduction Is Not Cost Reduction: An Empirical Study of End-to-End Efficiency in API-Based Coding Agents" (2026, preprint, not peer reviewed). ↩↩↩↩↩
How should you evaluate a cost change?
Evaluate any cost change by cost per successful task. The paper reaches the same conclusion: evaluate at the level of cost per successful task, including cache behavior, trajectory changes, and correctness, rather than token counts alone. A June 2026 DORA article likewise calls token volume an easily gamed input measure and suggests efficiency metrics such as cost per accepted change.
Cost per successful task = total agent spend in the period ÷ tasks completed successfully in the period
For example, say your team spends $3,000 on agents in a month and completes 200 issues that pass CI and review. That's $15 per successful task. If a compression tool drops spend to $2,700 but completions fall to 150, you're now paying $18 per task, so the change made things worse. These numbers only illustrate the calculation; they aren't measurements.
Before you use the formula, decide 3 things.
- Define success. Count states you can verify downstream, such as passing CI, an approved review, or a completed issue, rather than the agent reporting that it's done.
- Keep failed attempts in the numerator. If you drop the cost of runs that didn't succeed, the cost of rework disappears from the math.
- Know whether cost is an estimate. By default, the amounts Claude Code shows in
/usageand telemetry are calculated from token counts at list price (cost documentation). SettingmodelPricingin managed settings applies your contracted rates, but the figure is still an estimate, not an invoice.
I installed the tools without running a benchmark first. I cared more about staying under rate limits and usage limits than about the bill. Five days after installing them, I asked the agent whether token use on that task had gone down. I ran /rate-limit-options 16 times. I removed RTK and Headroom on September 16, and I didn't come across the paper covered here until September 29, 13 days later.
When your unit of work is an issue, we recommend defining cost per completed issue this way: add up the cost of runs that started in the period and have a confirmed link, not just an inferred one, to an issue completed in a given interval, then divide by the number of issues completed in that interval. Count each agent session as one run. When no issues were completed in an interval, leave the value blank rather than showing zero. Our docs page on linking runs to issues covers how runs are linked to issues.
How can Harnessforce help?
Cost per successful task requires putting run costs and the outcome of the work they served side by side. Harnessforce shows AI runs issue by issue.
Harnessforce can help you:
- Line up cost and outcome per issue: For each issue, see how many times AI ran, what it did, what it cost, and how CI and review went, then inspect traces, logs, and metrics.
- Roll up runs by issue: Total run counts and cost by issue on the Sessions page.
- Link runs to pull requests: Harnessforce links runs to issues and pull requests and puts CI and review results next to them. Inferred links are labeled as inferred.
- Assess project cost: Project overview rates Quality and Cost as On track, At risk, or Not measured. Until it has the data it needs, Cost shows Not measured along with the missing data.
- Work alongside your tools: Harnessforce doesn't replace the tools you already use; it runs alongside them.
Learn more on the Handling the reins page, talk to us.
This article was written with AI assistance and reviewed by the author.