Measured data · 91,086 agent calls
Where AI agent tokens go: Claude Code and Codex usage, measured
Three months of session logs, counted once per call and priced at list rates. New input barely registers. The bill comes from context the agent resends on every call.
01 / The data
One developer's agent logs, counted once per call.
The sample is one developer's own session logs: 65,009 Claude Code calls across 373 sessions from July 3 to October 1, 2026, and 26,077 Codex calls across 301 sessions from June 4 to September 30, 2026 (UTC). The work was software development across several projects.
The logs were parsed with llm-token-audit0.2.0, which counts each model attempt once and reconciles against the logs' own totals, then priced at the list rates published September 30, 2026. The result is API-equivalent cost: what these tokens cost at those rates, not what a subscription plan charged.
02 / Token mix
Cache reads and writes are 82% of the cost.
New, uncached input was 0.02% of Claude Code's input-side tokens. Cache reads were 97.5%: about 14.4 billion tokens, a mean of 222,036 per call. Codex showed the same pattern, with cache reads at 95.5% of its input.
| Token type | Cost | Share |
|---|---|---|
| Cache reads | $8,191.83 | 52.3% |
| Cache writes, 1-hour tier | $3,832.97 | 24.5% |
| Output | $2,364.26 | 15.1% |
| Cache writes, 5-minute tier | $875.40 | 5.6% |
| Uncached input | $392.16 | 2.5% |
Claude Code wrote 72.1% of its cache-write tokens to the one-hour tier, which Anthropic prices at twice the input rate, against 1.25 times for the 5-minute tier. Those writes alone were 24.5% of the cost. Trimming what you type into each turn changes almost nothing. The context the agent carries and resends sets the bill.
03 / Session length
A call late in a session carries 7 times the context of an early one.
Each call resends the conversation so far. Ordering each main-agent Claude Code session by time shows how the context per call grows:
| Call number in session | Calls | Median context tokens |
|---|---|---|
| 1 to 20 | 6,459 | 60,166 |
| 21 to 100 | 14,098 | 151,974 |
| 101 to 300 | 10,256 | 332,925 |
| 301 and later | 11,065 | 441,048 |
The 301st call and later re-read a median of 441,048 tokens, 7.3 times the 60,166 of the first 20, so each late call costs about 7 times as much in cache reads as an early one. Starting a fresh session resets that growth, and compacting the context reduces it.
04 / Concentration
10% of sessions drove 80% of the cost.
Of 581 sessions with priced usage, the most expensive one accounted for 37.1% of the total and the top five for 49.9%. The top 10% of sessions drove 80.2%. The median session cost $4.08.
Subagent calls were another 23.1% of cost. Each subagent builds and caches its own context, so a task that fans out to several subagents pays for several contexts.
Optimizing a typical session saves little. The savings sit in the handful of long, runaway sessions and the workflows that produce them.
05 / Model versions
Newer versions cut the price of the same tokens by over 40%.
Repricing the logged Claude Fable 5 tokens at Fable 5.1 rates lowers their cost from $6,206.22 to $3,507.79, 43.5% less. The Opus 5 tokens repriced at Opus 5.5 rates fall from $3,449.75 to $1,882.71, 45.4% less. For Fable, the whole drop comes from the cache-read price: Fable 5.1 reads cache at $0.25 per million tokens against $1 for Fable 5, and every other rate is unchanged. Opus 5.5 lowers every rate by 20% and its cache-read rate by 60%.
This reprices the same tokens. A newer model can use more or fewer tokens for the same task, so measure your own workload before assuming the full saving.
06 / Counting pitfalls
Naive log parsing more than doubles the count.
- Repeated lines. Claude Code writes usage on every streamed line of a response. Summing every line gives 33.3 billion tokens against 14.9 billion real, a 124.3% overstatement.
- Nested cached input. Codex reports cached input inside its input count. Adding the two double-counts cached tokens.
- Hidden fallback attempts. When Claude Code falls back to another model, the replaced attempt appears only in a nested field. Five such attempts carried 2,695,025 tokens that top-level usage leaves out.
The tool's log-format notes document each rule with the measurements behind it.
07 / Beyond coding agents
The same mechanics drive any production agent.
An agent that loops through tool calls resends its growing context on each step, whether it writes code or handles support tickets. Four checks carry over:
- Measure context per step.Track how prompt size grows across a run, not only the average.
- Cap or summarize long runs.Bound step counts and replace old history with a summary once it stops affecting results.
- Price the cache read.When most input is cached, the cache-read rate decides the model's real cost; see the September 2026 rate comparison.
- Count subagents separately.Report fan-out as its own line so its cost shows up next to its value.
08 / Reproduce
Run the same report on your own logs.
llm-token-audit is free and MIT licensed. It needs Python 3.9 or later, makes no network requests, and outputs counts only, never prompt or file content.
See where your agent's tokens go.
Clone the repository and run python3 -m llm_token_audit report.
09 / Limitations
One developer, one kind of work.
These logs come from one developer's software work. Other workloads, tools, and habits will produce different mixes, so treat the shares as one measured case.
About 503 million Codex tokens stay unpriced because OpenAI's pricing page no longer lists their models, and Codex logs do not report cache writes, so the Codex cost excludes them. Costs use the rates published September 30, 2026, not the rates in effect when each call ran.