Summing Claude Code's Transcript Usage? One API Response Can Appear Several Times A developer analysis of Claude Code's on-disk JSONL transcripts shows that a single API response containing multiple content blocks (thinking, text, tool_use) is written as several assistant entries that each repeat the full usage object, so naively summing lines overcounts tokens. In one session reported in issue #87303, summing cache_creation_input_tokens gave 1,075,420 versus 560,751 when counting each message.id once — a 1.92x overcount — and Anthropic closed the issue as documented behavior, stating that "consumers are expected to count each message.id once." The Agent SDK cost-tracking guide also warns that per-step output_tokens is a placeholder and that the real output count appears only in the final result message. An agent step that writes a sentence and then calls two tools is one API response. In the transcript Claude Code https://code.claude.com/docs/en/overview keeps on disk, that one response can be three lines, and every line carries the full usage object of the response. Sum the lines and you have counted the same tokens three times. The numbers are public. In a session posted to Claude Code's issue tracker in August 2026, a naive sum of cache creation input tokens came to 1,075,420. Counting each message.id once gave 560,751, a 1.92x overcount, and cache reads were over by 1.59x issue 87303 https://github.com/anthropics/claude-code/issues/87303 . Anthropic closed the issue the same day as documented behaviour. So if your cost script sums lines, the bug is in your script. A short Node script sums your own transcript both ways, so you can see the gap on your data. Claude Code stores each session as JSONL at ~/.claude/projects/