Where the tokens go
Why Claude Code uses
so many tokens.
We took our longest recorded Claude Code and Codex sessions apart to see what the model is actually sent. It's mostly not the conversation. It's tool output, sent again on every turn.
1. Every turn re-sends the whole session.
An agent's request includes everything so far. Over a long session, the content sent to the model added up to a median of about 340 times the largest context the session held for Claude Code, and about 170 times for Codex. Caching makes those re-reads cheaper, not free: about three quarters of Claude Code's input cost is re-reading.
2. Most of it is tool output.
Weighted by how often each piece was re-sent, this is what made up the input in our longest sessions:
| Content | Claude Code | Codex |
|---|---|---|
| Command output | 26% | 30% |
| File contents read | 9% | 28% |
| Commands and scripts the agent wrote | 20% | 18% |
| Code it wrote into files | 12% | under 1% |
| Browser screenshots and pages | 12% | – |
| Your messages | 9% | 19% |
| The agent's own replies | 10% | 3% |
Content measured from the recorded transcripts; images counted at their token cost, not their file size. The system prompt and tool definitions aren't in transcripts and aren't counted. Codex reads files with shell commands, so more of its reading shows up as file contents (more on Codex token usage). Your mix will differ: ours includes a lot of browser automation.
3. A lot of it is the same thing twice.
About half of all file-reading output, for both agents, was a file the session had already read. Sometimes the file had changed in between; often it hadn't. Either way, the earlier copy was still in the context and was re-sent on every turn after.
What helps
- Fresh sessions for unrelated tasks, and compacting before the context is at its largest.
- Short tool output: line ranges instead of whole files, quiet flags,
| tailon long logs. - Densilo, which does this automatically. It runs on your machine between the agent and the model. Old tool output the model has already seen is sent in short form, and the full text is kept so the model can fetch it back exactly. In our replays of long sessions, it cut input cost by up to 50% for Claude Code and up to 49% for Codex (medians 32% and 22%). How we measured, and what a replay doesn't show.
Step by step: how to reduce Claude Code token usage. Want the cost side? Try the token cost calculator.
See your own number.
Install Densilo and run densilo benchmark in a repository you work in. It replays your recent Claude Code and Codex sessions offline: no model is called and nothing leaves your machine.