# Where the money goes in a CI agent run

November 2, 2026 CI 5 min read

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. Half is the fixed prefix, a quarter is tool results and history, and a fifth is the model's own writing. On the shortest job, 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 50%, tool results and history 27%, thinking 3%, answer 20%.
- **Short jobs:** cache writes are 78% of the bill on the labels job and 42.2% to 47.2% on the longer fix jobs.
- **The rule:** a 5-minute write costs 25 times a read and a 1-hour write 40 times, 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 three jobs on Sonnet 5.5: the CI failure fix, the `@claude` fix and issue labels (90 runs).

| Part of the request | Share of cost |
| --- | --- |
| Fixed prefix: tools, system text, skill and agent lists | 50% |
| Tool results and history | 27% |
| Thinking | 3% |
| Answer and tool-call text | 20% |

The per-job split, the method and the command to rebuild it are public: [script output](https://github.com/mksglu/cm-ci-lab/blob/main/analysis/results/cost-split.txt) and [analysis README](https://github.com/mksglu/cm-ci-lab/blob/main/analysis/README.md).

Two parts are out of reach for any proxy: the answer and the thinking, 23% together. The other two parts, 77%, are what the request carries. That is where a saving can come from.

## Short jobs are mostly cache writes

The labels job makes 2.3 requests per run. The prompt is large, the work is small. Most of the cost is the first write of the prompt to cache: 78% of the bill. The fix jobs make 6 to 9 requests, and cache writes are 42.2% to 47.2% there.

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 (saved 2026-11-01, [ratios](https://github.com/mksglu/cm-ci-lab/blob/main/analysis/results/price-ratio.txt)):

| 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 5-minute write on Sonnet 5.5 costs $2.50 and a one-hour write costs $4. A read costs $0.10.

## The 25-to-1 rule

Count in units of the plain input price. On Sonnet 5.5 a 5-minute write is 1.25 units and a read is 0.05 unit. That is 25 to 1. A one-hour write is 2.0 units, which is 40 to 1. In the lab, 336 of 346 runs wrote only 5-minute cache.

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.05 per removed token. Any change inside the prefix breaks the cache from that point on, so the turn writes the rest again at 1.25 instead of reading it at 0.05. That costs about 1.2 units per token of *P*. Each later turn then saves 0.05 per removed token. You break even only when

**n x later turns > 24 x P**

For a 10,000-token prefix, you must remove 240,000 token-turns of text to come out ahead (390,000 at the one-hour price). 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 5.4k to 7.1k tokens smaller in the three jobs. That made the first write smaller and every later read smaller ([script output](https://github.com/mksglu/cm-ci-lab/blob/main/analysis/results/request1.txt)).
- **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](https://github.com/mksglu/cm-ci-lab/blob/main/confirm-1101/RESULTS-r2.md).

The saving is about a fifth and not more because the answer and the thinking, 23% 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 init
```

[Open the try page](https://contextmode.ai/try), or [copy the lab template](https://github.com/mksglu/cm-ci-lab/generate). The first post in this series, [how Context Mode cuts the cost](https://contextmode.ai/blog/how-context-mode-cuts-ci-agent-cost), names each lever.

[Get started free](https://console.contextmode.ai/login) [All posts](https://contextmode.ai/blog)
