Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchDeduplicating repeated assistant records by message ID can remove one source of overcounting, but it does not guarantee that a log total now represents unique token usage. The remaining sum may still include placeholder output counts, cumulative resumed-session results, overlapping parent and subagent totals, or legitimate processing of a large conversation context. Which explanation applies depends on the data source, Claude Code or SDK version, and fields your parser sums.
First, identify what your log total measures
Claude Code usage can be viewed through different surfaces: streamed Agent SDK messages, a completed SDK result, a local session transcript, or an export assembled by another tool. Anthropic’s SDK guidance describes how its SDK usage fields behave; it does not establish that every local Claude Code JSONL version exposes identical fields or snapshots. Before changing the parser, note the source, version, and accounting boundary: one response, one query, a resumed session, the main agent, or the entire agent tree.
Why message-ID deduplication helps—and where it stops
Anthropic’s Agent SDK cost documentation says that messages generated when Claude uses multiple tools in one turn can share the same ID, and instructs SDK users to count that ID once. In that documented case, summing every representation as a separate assistant response can overstate usage.
Apply that rule only after confirming the local records have the same meaning. Group candidate assistant records by message ID, inspect their usage objects, and count one shared response ID once when the records are repeated representations of the same response. Do not discard distinct response IDs simply because their text or usage values look alike. Message-ID dedupe addresses repeated representations; it does not correct errors in the choice of usage field or aggregation scope.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
Check whether the output count is final
The SDK guide warns that assistant-message output_tokens values can be placeholders based on what the API reported when a message began. For a completed SDK query, use the result message’s usage for the main-loop total, or modelUsage (also written model_usage) for per-model accounting that includes subagents. For streaming progress, use the documented message_delta usage events rather than treating a start-of-response placeholder as the final count.
Check whether you added cumulative results together
A call that resumes an SDK session can return usage that includes earlier spend in that session. Adding each resumed result to the previous result can therefore count earlier work again; use the latest appropriate result for the resumed-session total. Streaming-input mode has its own running-total and reset behavior, so aggregate according to those documented boundaries rather than adding every snapshot indiscriminately.
Rank #2
Check whether the total includes subagents
The SDK result’s usage covers the main loop and excludes subagent activity. modelUsage or model_usage is the documented choice for whole-tree, per-model token accounting. If a report combines a parent rollup with child traces, first establish whether those figures overlap; otherwise the same work could be represented in both.
| What you need to measure | SDK source to use | Important boundary |
|---|---|---|
| Output as it streams | message_delta usage events |
Progress during streaming, not a substitute for a completed result total. |
| Completed query, main loop | Result message usage |
Excludes subagent activity. |
| Per-model or whole agent tree | modelUsage / model_usage |
Use this rather than adding overlapping parent and child summaries. |
| Local transcript total | Version-validated transcript fields | SDK guidance alone does not prove every local JSONL record has the same semantics. |
Use this diagnostic sequence
- Record the source and version. Identify whether the data came from SDK stream events, a completed result, a local transcript, or a third-party export; record the Claude Code and SDK versions if known.
- Inspect repeated IDs. Group candidate assistant rows by message ID and compare their usage fields. Count one ID once only when the records represent the same response under the relevant format.
- Verify field finality. If you summed assistant-message
output_tokens, check whether these are start-of-response placeholders. Use the final result or documented stream deltas for the relevant SDK accounting task. - Verify the time boundary. Determine whether results are cumulative across a resumed session or streaming-input reset boundary. Do not add successive cumulative snapshots as if each began at zero.
- Verify scope. Decide whether the requested total is main-agent-only or includes subagents, and avoid combining summaries that may overlap.
- Compare with billing carefully. SDK cost estimates use a client-side price table and can differ from billed cost if prices or billing rules differ. Treat an estimate as an estimate, and use an authoritative billing source for a billing comparison.
A corrected parser can still show high usage
Claude Code sends conversation history and project context with later turns. As that context grows, the model may process substantial input even when the parser no longer counts duplicate message records. A high total is therefore not, by itself, proof of a remaining counting bug; it can reflect actual context processing.
Recommended Free Tools
Rank #3
What prevalence figures do—and do not—show
Frederick Douglas Pearce’s 2026 analysis reported duplicate assistant message IDs in 986 of 1,047 files (94%) in the author’s corpus and a 1.99× inflation from naive row summation in that corpus. These are corpus-specific observations, not Anthropic statistics or estimates of how often the issue occurs across Claude Code logs, and they do not identify the cause of any individual file’s remaining discrepancy. Anthropic has not established a general prevalence or typical inflation figure for this exact problem in the cited guidance.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Keep transcript samples safe
Anthropic’s compliance-session documentation describes deduplicating listed sessions by session ID and messages by message ID for that API. It also notes that captured transcript content may be unavailable or truncated in specified circumstances. This is guidance for that compliance API, not a guarantee about every local transcript format. Transcripts can contain prompts, tool results, URLs, credentials, or personal information; redact secrets and sensitive content before sharing a sample to debug a parser.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

