fix(opencodex): price usage by its recorded provider - #3676
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 6:18 AM ET / 10:18 UTC (Revision 8). ClawSweeper reviewWhat this changesPrices imported OpenCodex usage by its recorded provider, refreshes cached prices before fresh results, and preserves custom overrides and unknown costs. Merge readiness✅ Ready for maintainer review The fix remains necessary: current main and v0.60.3 retain model-only pricing for OpenCodex logs. The current head resolves the prior override-precedence findings, and no blocking defect was found. Priority: P2 Review scores
Verification
How this fits togetherCodexBar imports OpenCodex usage logs into a local SQLite cache and calculates spending estimates using custom prices and the public models.dev catalog. These estimates feed CLI JSON and supported subscription rows in the spend dashboard. flowchart TD
A[OpenCodex usage logs] --> B[Local usage cache]
B --> C[Recorded provider and model]
D[Custom prices] --> E[Price token classes]
F[Cached public catalog] --> E
C --> E
E --> G[Known or unknown cost]
G --> H[CLI and spend dashboard]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Retain provider-scoped estimates with existing override precedence, raw usage preservation, and explicit unknown costs. Do we have a high-confidence way to reproduce the issue? Yes: current main prices an OpenRouter record such as openai/gpt-5.4 through the model-only Codex calculation. This is source-established; the reviewer did not execute a reproduction. Is this the best way to solve the issue? Yes: the patch reuses existing catalog and override infrastructure while preserving legacy routes and stored usage, with focused compatibility coverage. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f13aaf15d748. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
Keep router model namespaces from changing subscription attribution, resolve exact provider prices, and preserve unknown costs when counts or required rates are absent. Refresh the existing public pricing cache for fresh opt-in loads. Preserve independently recorded cache classes and existing caller/application override conventions, with cache-only, free, incomplete-rate, overflow, route, and historical compatibility regressions. Co-authored-by: Alec Gutman <44984861+Chipagosfinest@users.noreply.github.com>
62090a0 to
67f1d5d
Compare
|
Landed in 5e15f7e. Thanks @Chipagosfinest! Verified with The actual rebuilt CLI also passed an offline, synthetic macOS 15.7.7 VM check through |
OpenCodex records its billing provider, but the previous pricing path used only the model name. An OpenRouter model such as
openai/gpt-5.4could be attributed to a Codex subscription or priced using the wrong provider. Missing token counts and an unpriced current day could also appear as zero cost.Use the recorded provider for attribution and exact catalog prices, preserve custom-price precedence, and keep unknown costs distinct from genuinely free usage. Fresh opt-in loads refresh the existing public pricing cache. This changes estimates for existing logs; it adds no collection source or subscription route.
The maintainer revision also preserves independent cache counters, including cache-only usage. Caller-supplied overrides keep independent token-class arithmetic; app-level overrides and OpenAI catalog pricing retain their historical input conventions. New provider catalog prices count each recorded class once, and arithmetic overflow remains unpriced.
Validation: 281 focused tests across 12 suites passed, covering provider routing, catalog prices, custom overrides, cache-only/free/missing-rate cases, overflow, disk import, fan-out, refresh, store compatibility, and architecture gates.
make checkpassed with zero violations after correcting test formatting. Independent code review found no actionable P0–P2 findings. Exact-head CI must finish successfully before merge.Contributor: @Chipagosfinest. The batch changelog will be rewritten after landing with this fix and contributor credit.
A production CLI check also passed in a disposable macOS 15.7.7 VM with synthetic logs and a seeded pricing catalog, network access denied, and Keychain access disabled. Six real imported SQLite rows produced 346 tokens, four priced requests, two unpriced requests, and $0.000768 in known list-price estimates. A cache-only request priced at $0.00015; an exact free rate stayed zero; missing cache-write rates left today's cost omitted. Historical OpenAI pricing remained $0.000244. Guest fixtures and synthetic defaults were removed after verification. This proves local import/storage/pricing, without claiming live provider billing or network catalog refresh.