Skip to content

fix(model): prevent Codex token double counting#146

Merged
Yif-Yang merged 1 commit into
microsoft:mainfrom
Yif-Yang:fix/codex-token-tracker-isolation
Jul 16, 2026
Merged

fix(model): prevent Codex token double counting#146
Yif-Yang merged 1 commit into
microsoft:mainfrom
Yif-Yang:fix/codex-token-tracker-isolation

Conversation

@Yif-Yang

Copy link
Copy Markdown
Contributor

Summary

  • give the Codex backend its own TokenTracker
  • prevent Claude and Codex summaries from aggregating the same shared tracker twice
  • add a non-mocked regression test that records one Codex call and requires exactly one aggregate call

Root cause

PR #112 added Codex as an optimizer and correctly aggregated its token summary, but Claude and Codex both referenced the same tracker from model.common. Aggregating both backend summaries therefore doubled calls and token totals.

Verification

  • 13 Codex optimizer tests passed
  • full suite: 313 passed, 6 skipped
  • git diff --check passed
  • independent read-only Claude Opus review found no blockers

@Yif-Yang Yif-Yang merged commit d267020 into microsoft:main Jul 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant