Skip to content

Codex usage statistics doubled or inflated - cc-switch

Quick fix

Upgrade to v3.19.2 and run "Rebuild Codex Usage" on the usage page to correct historical inflated data.

Error output
统计出的Codex用量极其夸张,20亿, 80亿非常离谱的统计数据
English translation

The calculated Codex usage is extremely exaggerated, with statistics like 2 billion or 8 billion being highly unreasonable.

The root cause is the counter handling mechanism in the Codex session log importer: when multiple independent cumulative counters interleave within the same rollout file, the old algorithm performs differencing across counters, causing usage to be inflated. Additionally, the fork/sub-agent usage double-counting issue introduced in v3.17.0 further worsened the statistics anomaly. Because Codex itself continuously operates on jsonl files on Windows without flushing to disk, the file modification time remains unchanged, causing cc-switch to judge the file as unchanged based on time and miss reading it, further leading to a mismatch between local statistics and relay station data. Historical inflated data will not self-heal and must be manually rebuilt once.

  1. Upgrade cc-switch to v3.19.2 or higher.

  2. Go to the "Usage Statistics" page.

  3. Run "Rebuild Codex Usage" once and wait for the historical inflated data to be corrected.

ToolCodex
Version3.16.1 - 3.19.0(受影响),v3.19.2 修复
PlatformsWindowsmacOS
Why are the statistics still incorrect after upgrading?
Historical inflated data will not self-heal. You must manually click "Rebuild Codex Usage" on the "Usage Statistics" page once for it to be corrected.
Why do cc-switch statistics not match the data from relay stations like sub2api/newapi?
Codex continuously operates on jsonl files on Windows without flushing to disk, causing the file modification time to remain unchanged. cc-switch then judges the file as unchanged based on time and misses reading it. After completely exiting Codex and restarting to enter the previous conversation, Codex will update the jsonl file's modification time, and cc-switch can read it normally.
Why does the Codex(Session) statistic metric exist?
This is a design issue with the statistic metric. The fix in v3.19.2 only corrects the values themselves and does not change the design of whether this metric is included in the total.
Why does the usage statistics contain a large number of unknown model requests?
This is related to a bug in the session log importer when parsing counters, causing massive anomalous requests to be recorded as unknown models. This can be resolved by upgrading to the fixed version and rebuilding usage.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.