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.
Symptom
Section titled “Symptom”统计出的Codex用量极其夸张,20亿, 80亿非常离谱的统计数据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.
Upgrade cc-switch to v3.19.2 or higher.
Go to the "Usage Statistics" page.
Run "Rebuild Codex Usage" once and wait for the historical inflated data to be corrected.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 21 real issues
- #2383多个codex 切换 导致额度显示不对
- #2411claude code 登录 codex 失效 Codex 令牌失效
- #2478官方的OpenAI Official显示已拦截无法切换使用官方的额度
- #2858Codex 用量统计包含大量未知模型请求
- #3603ds 通过 ccswitch 中转到 codex 后,哪怕没有任何会话任务也在自动消耗 token
- #3814Codex 用量统计异常
- #3840codex 显示余额不足的图层可以去掉吗
- #3936使用codex依然被双倍统计的bug
- #3993codex 显示余额不足的图层可以去掉吗
- #4306Codex Session 用量未应用 Codex 默认成本倍率
- #4614用量统计/路由 重复以及错误计费
- #4657你好为什么走api的模式然后是还是会消耗正好登录的账号的额度呢
- #5150codex用量查询会出现两个结果
- #5564模型使用量统计正确么?
- #5606Codex切换启用模型后,新模型无法使用
- #5633最新版 v3.18.0统计codex使用量似乎还是不对
- #5649Claude Code /branch 会话在 Session Manager 中难以找回父会话;且文档路径与实现不一致
- #5942项目归档后,cc没有使用量显示
- #6650OpenAI Official 用量显示错误
- #6802是token统计有问题还是我的pro20x真的只有周1100刀?
- #683926号下午更新codex版本后,发生订阅与api同时消耗额度
- 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.
Related problems
Section titled “Related problems”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.