Skip to content

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.

Error output
codex创建子代理采用复制模式的时候,会被错误的统计全量用量
English translation

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.

  1. 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.

  2. On the first launch after upgrading, session-sourced historical figures are backed up and rebuilt back to their true values automatically.

  3. Note: duplicate proxy rows already written to the database before the upgrade are not cleaned up automatically, but no new duplicates are produced afterwards.

ToolCodex
Version3.17.0
PlatformsWindowsmacOS
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.

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.