Skip to content

“导入 0 条, deferred 27–31 个” — Codex Usage Is Not Counted

Quick fix

If it persists after upgrading, wait for the paginated rollout index fix. Disabling auto-sync stops repeated full reads but does not restore statistics.

Error output
CODEX-SYNC 每轮「导入 0 条, deferred 27–31 个, 扫描 1122 个文件」,deferred 数量随新会话持续增长,跨重启、跨升级不恢复
English translation

Each CODEX-SYNC run shows 「导入 0 条, deferred 27–31 个, 扫描 1122 个文件」. The deferred count continues to increase with new sessions and does not recover across restarts or upgrades.

When local routing is disabled, Codex usage comes from session logs. After a long session is paginated, continuation filenames use `<线程ID>_<页ID>.jsonl`, but the importer indexes them only by the page ID at the end of the filename. When a subagent or branched session references the root thread, the importer can therefore find only the first page, which has stopped growing. It incorrectly concludes that the parent rollout has not reached the child fork time and permanently marks the child file as deferred, so the GPT-5.6-Sol `token_count` is not written to the usage records. The proposed fix is to register continuation pages under the thread's own UUID as well, concatenate the parent timeline in pagination order, and only then evaluate the cutoff. The thread says that PR #7093 was submitted, but provides no confirmation that it was merged or released.

#5870 reported the same missing GPT-5.6-Sol usage, but there were not enough logs at the time to confirm whether pagination and fork behavior were also responsible. The maintainer only confirmed that releases after 3.18 had gradually fixed issues such as skipped continuation files and delayed reads of files still being written, and requested retesting with the latest version. Different users also reported different results for Luna, Terra, review, and GPT-6-Astra, so the issue does not affect every model uniformly.

  1. First upgrade to the latest version and retest. If only some models are still counted, as requested by the maintainer, record the cc-switch version, operating system, the filename format of the corresponding session files under `~/.codex/sessions`, and the `CODEX-SYNC` lines from the logs.

  2. If the logs continue to show `导入 0 条` while the deferred count keeps increasing, check for paginated files named `rollout-<时间>-<线程ID>_<页ID>.jsonl` and inspect the child session's `forked_from_id` or `parent_thread_id`. This can confirm whether the paginated rollout and fork indexing issue applies.

  3. Until an official fix is available, disable `sessionAutoSyncEnabled` and restart cc-switch to prevent deferred files from being reread in full every 60 seconds. Manually use “Rebuild Codex Usage” when needed. This workaround stops automatic updates, and the thread does not confirm that a manual rebuild restores every missing record.

  4. To attempt recovery of existing missing data, use the recovery script provided in a comment on #7084. Keep the default dry-run first to verify the time range and entries to recover, and use `--apply` only after confirming that the database is backed up and the output is correct. The script was provided by a user, and the thread contains no success report, so it should not be treated as an official maintainer-confirmed fix.

ToolCodex
Version受影响版本 3.16.3 - 3.20.3
PlatformsmacOSWindows
Why is only GPT-5.6-Sol missing while the usage page still shows Luna, review, Terra, or GPT-6-Astra?
Actual behavior varied across the thread. The identified pagination and fork issue permanently defers specific rollout files, so only usage for models recorded in those files is missing; other sessions or models may still import normally.
Can restarting cc-switch restore GPT-5.6-Sol usage?
It is not guaranteed. The reporter in #5870 did not recover the records after restarting, and the #7084 reproduction also showed that the deferred state persisted across restarts and upgrades.
Why should Codex usage still be available when local routing is disabled?
The maintainer explained that this usage is imported from Codex session logs rather than recorded through local routing. Therefore, leaving local routing disabled should not by itself cause main-model records to be missing.
Is there a temporary workaround?
Disabling `sessionAutoSyncEnabled` and restarting can reduce continuous disk reads from about 579 MiB/min to about 3 MiB/min, but the usage dashboard will no longer update automatically. Use “Rebuild Codex Usage” manually when needed.

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.