fix(usage): Codex Fast and Ultrafast now cost what they bill #15101
main fromrefs/pull/15101/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubThe Usage tab priced every Codex request at the standard rate. Ultrafast bills at 6x and Fast at 2x for GPT-6 Astra, so heavy Ultrafast use looked far cheaper than it was.
On one machine, the last 30 days of Codex went from $1,408 to $3,364. Ultrafast Astra alone went from $353 to $2,116.
Fix#
Codex writes the service tier (default, priority, ultrafast) to thread_settings_applied events. The usage scan skipped those events.
- The Codex reducer now carries the tier forward, the same way it carries the model.
- Pricing reads LiteLLM's
_priorityand_ultrafastrates. Claude fast mode keeps its published multiple. If a model publishes no rates for a tier, that tier bills at the standard rate. - When Codex leaves out
service_tier, no tier was requested, so the request bills as standard.
Saved usage is kept across the cache upgrade#
The scan cache keeps usage for transcripts that were deleted from disk. Earlier cache version bumps lost that history.
- v4 Codex entries are kept. A rollout that is still on disk re-parses with its tier. A deleted rollout keeps its saved usage at the standard rate.
- Each cache version now writes its own file (
usage-scan-cache-v5.json). An older server that shares~/.t3/userdatakeeps its own cache, and neither version overwrites the other.
ccusage reads the same event but treats ultrafast as unknown, so it under-reports Ultrafast too.
Proof: new tests for tier parsing, tier pricing, resume across the parse boundary, and a v4 cache upgrade with one deleted rollout. The upgrade test fails for each of three broken variants. I also ran the new reader and pricing over 431 real Codex rollouts.
Reviewed with sol-loop: 3 rounds with GPT-6.1 Sol on high.
Created with Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 4.9 KiB 4.9 KiB −40 B (−0.8%) 6.8 KiB ✅ Codex Thread snapshot wire 3.7 KiB 3.7 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.1 KiB −40 B (−3.3%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.4 KiB 20.4 KiB −41 B (−0.2%) 29.3 KiB ✅ Codex Live turn messages 2 1 −1 (−50.0%) 8 ✅ Claude Total thread wire 4.9 KiB 4.9 KiB −41 B (−0.8%) 6.8 KiB ✅ Claude Thread snapshot wire 3.7 KiB 3.7 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB −41 B (−3.4%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 20.8 KiB 20.7 KiB −41 B (−0.2%) 29.3 KiB ✅ Claude Live turn messages 2 1 −1 (−50.0%) 8 ✅ Baseline:
6108ef3· PR result:40adc07· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 106.1 KiB
- Claude decoded thread snapshot: 106.4 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
- Review profile: CHILL
- Plan: Team
- Run ID:
86606b7b-af98-4196-9989-84b9939fd111
📥 Commits
Reviewing files that changed from the base of the PR and between 3e4f0d1a597282f5c83015d1e1b7c68b9f622c5f and 40adc07dd703e1122c171271078dc0b6b5a5e915.
📒 Files selected for processing (4)
apps/server/src/usage/UsageService.test.tsapps/server/src/usage/UsageService.tsapps/server/src/usage/usageScanCache.test.tsapps/server/src/usage/usageScanCache.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/server/src/usage/usageScanCache.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
Walkthrough#
Usage records now carry standard, fast, or ultrafast speed. Codex transcript parsing tracks service tiers, pricing selects tier-specific rates, and the scan cache stores and validates speed values.
Changes#
Usage speed attribution and billing
Layer / File(s) Summary Record and carry usage speed
apps/server/src/usage/usageTranscripts.ts,apps/server/src/usage/usageTranscriptReader.ts,apps/server/src/usage/*UsageReader.ts,apps/server/src/usage/usageTranscripts.test.ts,apps/server/src/usage/usageTranscriptReader.test.ts,apps/server/src/usage/usageTranscriptStreaming.test.tsUsage records replace the boolean fastfield withspeed. Codex parsing carries service-tier settings into usage records. Other provider readers assign standard or fast speed as described by their parsers. Tests cover tier mapping and resume behavior.Tier-specific usage pricing
apps/server/src/usage/usagePricing.ts,apps/server/src/usage/usagePricing.test.ts,apps/server/src/usage/usageAggregation.test.tsRate entries support standard, fast, and ultrafast token rates. Pricing and cache-savings calculations select rates by record speed and fall back to standard rates when a speed-specific rate is unavailable. Tests cover published Codex rates and fallback behavior. Speed-aware scan-cache format and migration
apps/server/src/usage/usageScanCache.ts,apps/server/src/usage/usageScanCache.test.ts,apps/server/src/usage/UsageService.ts,apps/server/src/usage/UsageService.test.tsThe cache advances to version 5 and stores speed indexes. Decoding validates speed values and resets the scan position for older Codex entries. UsageServicecan load a legacy cache and mark it for migration.Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)#
sequenceDiagram participant usageTranscriptReader participant parseCodexLine participant CodexScanState usageTranscriptReader->>parseCodexLine: forwards Codex transcript lines parseCodexLine->>CodexScanState: updates speed from service tier parseCodexLine-->>usageTranscriptReader: returns usage record with speedSuggested reviewers:
maria-rcks,juliusmarmingeMerge Risk: ⚪ Minimal · up to
40adcNo issue identified here needs resolution before merge; normal checks remain appropriate.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 45.16% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 15 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. Title check ✅ Passed The title clearly summarizes the main change: Codex Fast and Ultrafast requests now use tier-specific pricing. Description check ✅ Passed The description explains the problem, the pricing and cache changes, and the verification performed. It does not include the template’s Scope and approval section or state explicit test outcomes, but … - Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
- Commit to this branch
- Create a new PR
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — The PR changes production usage parsing, model-rate selection, cache migration, and displayed cost calculations, including potentially large cost changes for existing Codex Fast and Ultrafast requests. Because it directly affects billing and metering behavior, human review is required.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).