Fix token cost calculation discrepancies#995
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bfb325c802
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…toml The fast/priority flag was read from the current config.toml and applied to the entire 30-day history, so enabling priority for a single task retroactively repriced every past day (~2x) and published the inflated figures to the synced iCloud history until the setting was reverted. Codex CLI (since ~Jul 2026) records the tier in each session rollout as thread_settings_applied lines. Track it per session the same way the scanner already tracks the model from turn_context, stamp each event, and price only the turns that actually ran fast at fast rates. Sessions without tier metadata price at standard rates; config.toml is no longer consulted at all. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Pushed cfdfdd0, which closes the remaining gap in how the fast/priority tier is detected. WhyThe multiplier corrections in this PR are right (verified against OpenAI's published priority table: 2.5× for GPT-5.5, 2× for GPT-5.4/5.6), but the detection still read What changed
Tests
|
TL;DR
Corrects local token-cost estimates for large and priority-tier Codex requests, preserves whether cache discounts were actually published, and counts nested Claude advisor usage under the advisor model. It also normalizes Codex
-fastaliases before provider pricing and verifies that persistedclaude -pusage is included.What was happening
-fastcould retain Cursor-scaled rates and bypass the Codex long-context and priority switches.claude -pand--no-session-persistencebehavior unclear.What this changes
-fastaliases through the unscaled base model, then applies the Codex multiplier exactly once for both short and long-context requests.advisor_messageiterations into deduplicated entries priced under their own model while leaving ordinary iterations in the parent totals.claude -p(sdk-cli) records and documents that--no-session-persistencewrites no log for OpenUsage to read.Heads-up
usage.speedremains authoritative. No date-derived fast-mode override was added because post-retirement Opus 4.6 responses already reportstandard; overriding that field could misprice real events.claude -pcounts when Claude persists the session. Calls using--no-session-persistencecannot be recovered from Claude's local history because that flag intentionally prevents the usage record from being written.Tests
swift test --filter 'CodexLogUsageScannerTests|ClaudeLogUsageScannerTests|ModelPricingTests'swift test— 1,144 XCTest cases passed, 3 opt-in tests skipped; 3 Swift Testing cases passed../script/build_and_run.sh verify— release build, signing, relaunch, and process verification succeeded. The existing icon compiler fallback usedassets/AppIcon.prebuilt; the local build had no matching iCloud provisioning profile.