You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can reproduce inflated Codex totals with the current released CLI (@ccusage/codex18.0.8).
On my local logs, the overcount comes from summing info.last_token_usage even when consecutive token_count events carry the same cumulative info.total_token_usage.
I checked this against my own session JSONL files and local Codex SQLite state, and PR #824 appears to be the correct fix for this specific duplicate-total pattern.
Summary
I can reproduce inflated Codex totals with the current released CLI (
@ccusage/codex18.0.8).On my local logs, the overcount comes from summing
info.last_token_usageeven when consecutivetoken_countevents carry the same cumulativeinfo.total_token_usage.I checked this against my own session JSONL files and local Codex SQLite state, and PR #824 appears to be the correct fix for this specific duplicate-total pattern.
Version
@ccusage/codex:18.0.8Current released output
Running:
reported:
totalTokens = 8,321,045,582Local audit of the same closed window
I audited the matching JSONL files under:
~/.codex/sessions/2026/03/01~/.codex/sessions/2026/03/02~/.codex/sessions/2026/03/03~/.codex/sessions/2026/03/04~/.codex/sessions/2026/03/05and compared them with the corresponding thread totals in
~/.codex/state_5.sqlite.Across that closed window on my machine:
88token_countevents:66,386total_token_usage:42,869sum(last_token_usage.total_tokens)):8,299,097,962last_token_usagewhentotal_token_usageis unchanged):2,899,127,807threads.tokens_used:2,899,127,807So for this dataset, the PR #824 logic matches the local SQLite totals exactly, while the current released logic overcounts by about
2.86x.Single-session reproduction
For this session file:
rollout-2026-03-04T00-00-40-019cb46e-1a1c-79f2-bc67-6551633c9e03.jsonlI measured:
token_countevents:8,5455,7031,231,236,178411,914,227sum(diff(total_token_usage.total_tokens)):411,914,227threads.tokens_used:411,914,227So the single-session case also lines up exactly with PR #824.
Why I think PR #824 is the right fix
This is the exact pattern in my logs:
token_countevent is emitted.token_countevent repeats the samelast_token_usage.total_token_usagedoes not advance.last_token_usageagain.PR #824 adds the missing guard for that case and makes my local totals line up with both:
total_token_usagedeltas in the JSONL logsthreads.tokens_usedvalues instate_5.sqliteRelated PR