Skip to content

Claude Code Token Logs Overcount Usage by 2.5x. Here Is How to Count Them Correctly

Updated November 3, 2026 · first published November 3, 2026

Claude Code writes the same assistant message to its log several times as the reply streams. Summing every usage line in October gave us 21.3 billion tokens and $12,438 of list-price value. Counting each message once gave 8.4 billion tokens and $4,323. The raw sum overcounts by about 2.5x in tokens and 2.9x in dollars.

2.5x
token overcount if you sum every line
175,884
usage lines for 70,592 unique messages
60%
of lines were repeats of an earlier message
14%
output tokens missed by keeping the first line only

Published 3 November 2026 · Claude Code transcripts, 1 October to 3 November 2026 (UTC; 1 to 3 November partial)

Why does one message appear several times?

Each assistant entry in a Claude Code transcript (~/.claude/projects/.../*.jsonl) carries a usage object with input, output, cache-write and cache-read token counts. In our logs the same pair of message.id and requestId shows up on several lines, and later lines carry larger output counts than earlier ones. We did not trace every cause; the pattern is consistent with a reply being written as it streams. Whatever the cause, summing all lines counts the same request more than once. Of 175,884 usage lines in the window, only 70,592 were distinct messages.

How wrong is the raw sum?

Three ways to count one month of Claude Code usageSumming every log line gives 21.3 billion tokens and $12,438; counting each message once gives 8.4 billion and $4,323.Sum every line21.3B tokensFirst line per message8.4BOne per message (max)8.4BSum every line$12,438 list valueFirst line per message$4,297One per message (max)$4,323TOKENS (input, output, cache write, cache read)LIST-PRICE VALUE
The same October transcripts counted three ways. Values are API list prices from Anthropic's pricing page, with cache writes priced at the logged 5-minute and 1-hour split. This is value at list prices, not a bill.

The raw sum is 2.5x too high in tokens and 2.9x too high in dollars. Dollars inflate more than tokens, which means the repeated lines were weighted toward the more expensive token types; we did not break that down further.

Why keeping the first line is also wrong

The obvious fix is to keep the first line of each message. That undercounts output, because the first line is a partial snapshot. We keep the largest value of each field across all lines that share the same message id and request id.

Output tokens missed by keeping only the first log line, by modelPercent of output tokens that the first log line misses compared with the largest value on any line of the same message.Claude Haiku 4.5 (167 msgs)99.6%Claude Haiku 5.5 (6,300 msgs)88.2%Claude Sonnet 5.5 (25,440 msgs)15.7%Claude Opus 5.5 (38,379 msgs)0.5%Claude Fable 5.1 (223 msgs)0.0%
Output tokens missed when keeping only the first line of each message, by model (models with more than 100 messages). In total the first-line method missed 14% of output tokens (33.1 million against 38.5 million).

The gap varies by model: Claude Haiku 4.5 lost 100% of its output tokens, while Claude Fable 5.1 lost 0.0%. In dollars the effect was small here ($4,297 against $4,323, about 0.6%) because output was a small share of our token volume. A workload that writes more and reads less would feel it more.

Three more ways agent logs mislead

How we counted

  1. Read assistant entries that have a usage object, between 1 October and 3 November 2026 (UTC). Skip synthetic placeholder messages.
  2. Key each entry by message.id plus requestId. If neither exists, key by file and entry id.
  3. For each key keep the maximum of every usage field across its lines. Include sub-agent (sidechain) messages, which are logged in the same files.
  4. Price tokens at Anthropic's list prices (checked 3 November 2026): for example Opus 5.5 at $4 input, $0.20 cache read and $20 output per million tokens, and Sonnet 5.5 at $2, $0.10 and $10. Cache writes use the logged 5-minute and 1-hour split. Haiku 5.5 uses its higher rate for prompts over 100,000 tokens, which we estimate per message from its input-side tokens.

What this does not tell you

What to do with this

  1. Deduplicate before you sum. Any dashboard that adds up log lines is probably overcounting. Ask what its key is.
  2. Use the maximum, not the first line, per message.
  3. Reconcile to a bill from the provider or gateway once a month. See LLM token tracking and AI observability for what a ledger needs.
  4. Do not trust a zero. Track tokens even where the price is free.

For the usage view this feeds, see Claude Code in October: tokens, cache and list-price value and how to check and reduce Claude Code token usage.

Frequently asked questions

How do I count Claude Code tokens correctly?

Read the assistant entries in the transcript files, key each by message id plus request id, and keep the maximum of each usage field across the lines that share the key. Summing every line counted our October usage 2.5 times too high.

Why do Claude Code logs show the same message more than once?

In our transcripts the same message id and request id appeared on several lines (175,884 lines for 70,592 unique messages), with later lines carrying larger output counts. That pattern is consistent with a reply being logged as it streams; we did not confirm the cause with Anthropic.

Is keeping the first line per message good enough?

It undercounts output tokens, because the first line is a partial snapshot. We missed 14% of output tokens overall, and up to 100% for one model, though the dollar effect was only about 0.6% on our mix.

Does the list-price value equal what I paid?

No. It is the cost of the same tokens at Anthropic's published API prices. A subscription or a gateway discount changes what you actually pay, and the logs contain no dollar amounts.

Related


Want this applied to your stack? Bring the provider bills, gateway logs, and top workflows; we will map the cost drivers and savings path. Book a free audit →

Back to finopsllm.com