Codex sub-agents in copy mode have their full usage counted wrongly - Codex
Quick fix
Upgrade to v3.18.0, fixing usage double-counting from sub-agent copy mode and duplicate proxy streaming records inflating the totals.
Symptom
Section titled “Symptom”codex创建子代理采用复制模式的时候,会被错误的统计全量用量When codex creates a sub-agent in copy mode, the full usage is counted wrongly
When a sub-agent is created in copy mode in Codex, it loads the parent session history. The statistics module wrongly counts that history as real consumption, double-counting the usage.
Separately, on the proxy streaming record path, a request missing a message_id or a recognisable session_id falls back to a random UUID. So when the same upstream response is proxied or replayed several times, the database cannot deduplicate by primary key, producing many duplicate usage records and badly inflating the statistics.
Upgrade CC Switch to v3.18.0 or newer. The parser layer resolves the sub-agent double counting at its root, and proxy usage now writes idempotently against a stable response-level key.
On the first launch after upgrading, session-sourced historical figures are backed up and rebuilt back to their true values automatically.
Note: duplicate proxy rows already written to the database before the upgrade are not cleaned up automatically, but no new duplicates are produced afterwards.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 3 real issues
- A reverse-proxied Antigravity through Claude Code with the local proxy shows requests succeeding but no usage is counted. What now?
- Check the proxy is actually enabled — usage is only counted with the proxy on.
- A managed xAI OAuth Provider cannot query the Grok Billing quota and upstream returns 404. What now?
- Fixed in a later version. Native quota queries for a managed xAI OAuth Provider are now supported, with the access token injected and refreshed automatically when the script runs.
- Will the false statistics records from before be deleted automatically after upgrading to v3.18.0?
- No. Duplicate proxy rows written before the upgrade are not cleaned up automatically, though session-sourced historical figures are rebuilt back to their true values and no new duplicates are produced.
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.