Where the money goes in a CI agent run
Before you cut a bill, find what is in it. We split the cost of CI agent runs, without Context Mode, by the part of the request that caused it. A third is the fixed prefix, a third is tool results and history, and a little over a third is the model's own writing. On short jobs, 65% to 78% of the money is cache writes. One price rule explains why: a cache write costs far more than a cache read.
TL;DR
- The split: fixed prefix 33%, tool results and history 33%, thinking 7%, answer 27%.
- Short jobs: cache writes are 65% to 78% of the bill.
- The rule: a write costs at least 20 times a read, so a prefix that is rewritten costs the most.
The split
We took direct runs of CI jobs (an agent, a model, no Context Mode) and priced every token the provider reported. Then we grouped the cost by where the tokens came from. This is the mean over the areas we ran.
| Part of the request | Share of cost |
|---|---|
| Fixed prefix: tools, system text, skill and agent lists | 33% |
| Tool results and history | 33% |
| Thinking | 7% |
| Answer and tool-call text | 27% |
Per-area splits, with the tool mix beside them, are in the lab notes: night round notes.
Two parts are out of reach for any proxy: the answer and the thinking, 34% together. The other two parts, 66%, are what the request carries. That is where a saving can come from.
Short jobs are mostly cache writes
A review or a triage job makes two or three requests. The prompt is large, the work is small. Almost all of the cost is the first write of the prompt to cache. On those short jobs, cache writes are 65% to 78% of the bill.
That is a useful fact. It tells you to attack the write, not the read.
The prices
List prices in USD per million tokens, from the provider's price page (read 2026-10-31):
| Model | Input | 5m write | 1h write | Read | Output |
|---|---|---|---|---|---|
| Sonnet 5.5 | $2 | $2.50 | $4 | $0.10 | $10 |
| Opus 5.5 | $4 | $5 | $8 | $0.20 | $20 |
Look at the write and read columns. A one-hour write on Sonnet 5.5 costs $4. A read costs $0.10.
The 20-to-1 rule
Count in units of the plain input price. At the one-hour setting that Claude Code uses, our cost model bills a write at 2.0 units and a read at 0.1 unit. That is 20 to 1. On Sonnet 5.5 the read is cheaper still, so the gap is wider.
The rule has a sharp edge. Say you remove n tokens from a cached prefix of P tokens, and the next turn would have been a cache hit. You do not save 0.1 per removed token. Any change inside the prefix breaks the cache from that point on, so the turn writes the rest again at 2.0 instead of reading it at 0.1. That costs about 1.9 units per token of P. Each later turn then saves 0.1 per removed token. You break even only when
n x later turns > 19 x P
For a 10,000-token prefix, you must remove 190,000 token-turns of text to come out ahead. Fewer tokens in the request can mean a higher bill. We have seen it: bytes removed and dollars saved are two numbers, and they can have opposite signs.
What we do with the rule
- Cut the prefix once, then keep it still. On the gateway arm, request 1 was 6.1k to 8.1k tokens smaller in every area. That made the first write smaller by about 3.1k to 3.7k units and made every later read smaller. Between 31% and 74% of the saving came from those reads (lab notes).
- Make the next run read, not write. The per-run git-status block moves behind the stable part, so run 2 reads the prefix that run 1 wrote.
- Pay for the long cache only where it wins. A one-hour write costs $1.50 more per million than a five-minute write on Sonnet 5.5. It is worth it when reruns come often.
- Fold the end, not the start. Tool output sits late in the request, after the cached part. Folding it changes tokens that were never going to be read from cache.
The total
On the CI failure fix job with Sonnet 5.5, the average run cost $0.0502 direct and $0.0420 through Context Mode. That is a 22.8% saving, 95% range 11.6 to 32.2%, on 16 tasks, or $8 per 1,000 runs. The tests passed Tests pass 16 of 16 direct, 15 of 16 with Context Mode (McNemar p = 1). Plan and rows: RESULTS-r2.
The saving is about a fifth and not more because the answer and the thinking, 34% of the bill, stay as they are.
Check your own split
Run a job on the try page and see your saving with your own key, or rerun our tests in your own repo.
curl -fsSL https://claude.ai/install.sh | bash
npx @context-mode/cli login
npx @context-mode/cli ci initOpen the try page, or copy the lab template. The first post in this series, how Context Mode cuts the cost, names each lever.