Codex cost: GPT-6.1 Sol long-context pricing starts at 200K instead of 272K
Bug
CodexBar 0.72.0 (164), macOS, Codex local session costs enabled: GPT-6.1 Sol requests with 200,001–272,000 input tokens receive long-context pricing, although OpenAI's threshold is more than 272,000 input tokens.
Evidence
The cached models.dev OpenAI entry for gpt-6.1-sol contains these USD-per-million rates:
{"input":2,"cache_read":0.1,"output":10,"cache_write":2.5,"context_over_200k":{"input":4,"cache_read":0.2,"output":15,"cache_write":5}}
ModelsDevPricing.swift translates the presence of context_over_200k into a literal threshold of 200,000.
resolvedCodexPricing uses the bundled threshold when available, otherwise this catalog threshold. GPT-6.1 Sol has no bundled threshold override in this version. GPT-6 Astra already has a 272,000 override.
OpenAI's GPT-6.1 Sol pricing specifies input $2, cached input $0.10, output $10 per million; full-request long-context multipliers apply only above 272K input tokens.
Minimal calculation example (synthetic)
Standard service tier, one request, no cache writes:
- Model: gpt-6.1-sol
- Input: 210,000 (includes 200,000 cached)
- Output: 1,000
Expected: (10,000 × 2 + 200,000 × 0.1 + 1,000 × 10) / 1,000,000 = $0.050.
With the current 200K threshold: (10,000 × 4 + 200,000 × 0.2 + 1,000 × 15) / 1,000,000 = $0.095.
This example is derived from the v0.72.0 pricing path, not a claim that a Swift test was run. An independent audit of local request records and the app's cost cache found this same threshold error in actual estimates.
Expected fix / regression coverage
Use the documented model threshold rather than inferring it from the legacy catalog field name. Cover input counts 200,000, 200,001, 272,000 and 272,001, including cached input. Reprice affected cached estimates after correction.
This pricing issue is separate from the duplicate ledger/token_count observations tracked in #4289; correcting that duplication alone will leave this pricing error. Private logs and identifiers are intentionally omitted.
Codex review: this still needs some work. Reviewed October 6, 2026, 4:18 AM ET / 08:18 UTC.
Summary Current main still contains the reported threshold error; the related accounting fixes do not address it. This is a bounded, source-proven repair candidate.
Likely related people: Peter Steinberger and urda (medium-confidence routing from pricing history).
Reproducibility: yes. from source: seed the supplied OpenAI catalog entry and price the 210,000-input request to obtain $0.095 instead of $0.050. No test or live scan was executed in this read-only review.
Next step No discovered open PR owns this threshold correction; establish the failing fixture and implement one focused pricing repair with cached-report regression coverage.
Review details
Best possible solution:
Use a documented model-specific 272K threshold through the existing resolver and automatically refresh affected estimates while preserving cached request history.
Do we have a high-confidence way to reproduce the issue?
Yes, from source: seed the supplied OpenAI catalog entry and price the 210,000-input request to obtain $0.095 instead of $0.050. No test or live scan was executed in this read-only review.
Is this the best way to solve the issue?
Yes, a model-specific threshold correction follows the existing supported pattern; changing the generic catalog threshold globally would incorrectly affect other models.
AGENTS.md: found and applied where relevant.
Codex review notes: model internal, reasoning medium; reviewed against 6a26b2e9b1b6.
Label changes
Label changes:
- add
P2: A model-specific threshold inflates local cost estimates without changing actual provider billing or blocking use. - add
impact:other: The concrete impact is inaccurate displayed API-equivalent spend, outside the other owned impact classes. - add
issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label. - add
clawsweeper:source-repro: Current issue advisory state selects this label. - add
clawsweeper:queueable-fix: Current issue advisory state selects this label. - add
clawsweeper:fix-shape-clear: Current issue advisory state selects this label.
Label justifications:
P2: A model-specific threshold inflates local cost estimates without changing actual provider billing or blocking use.impact:other: The concrete impact is inaccurate displayed API-equivalent spend, outside the other owned impact classes.
Evidence reviewed
Acceptance criteria:
- make test-fast FILTER='CostUsagePricingTests|ModelsDevPricingTests|CostUsageAstraPricingTests|CostUsageCacheWideMigrationTests'
- make check
- make test
- git diff --check
What I checked:
- Current source establishes the incorrect threshold: ModelsDevModel.pricing assigns 200,000 whenever context_over_200k exists. The Codex resolver prefers a bundled threshold but the complete bundled table has no GPT-6.1 Sol entry. The scalar calculator compares total input, including cached tokens, against that resolved threshold. With the supplied catalog fixture, the 210,000-input example therefore resolves to $0.095 rather than $0.050. (
Sources/CodexBarCore/Vendored/CostUsage/ModelsDevPricing.swift:249, 6a26b2e9b1b6) - Existing model-specific repair seam: resolvedCodexPricing uses bundled?.thresholdTokens before the catalog threshold while retaining catalog rates. GPT-6 Astra and earlier GPT models already use documented 272,000 thresholds; GPT-6.1 Sol is absent. Normalization does not redirect GPT-6.1 Sol to one of those entries. (
Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift:609, 6a26b2e9b1b6) - Official pricing contract: Opened the official GPT-6.1 Sol model page at https://developers.openai.com/api/docs/models/gpt-6.1-sol. It specifies $2 input, $0.10 cached input, $2.50 cache writes, and $10 output per million tokens, with full-request long-context multipliers only above 272K input tokens.
- Latest release also lacks the override: Read the v0.72.0 pricing file through GitHub contents. Its bundled table includes Astra but no GPT-6.1 Sol override, and its resolver has the same bundled-or-catalog threshold selection. This is not established as fixed in either the latest release or inspected main. (
Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift:609, cfee869f3181) - Cache correction can use existing mechanisms: The pricing key includes the bundled pricing fingerprint, and refresh planning detects changed keys. Stored request rows are priced through codexResolvedCostUSD on read; authoritative monetary amounts take precedence. Regression coverage should verify retained reports refresh and preserve rows, checkpoints, custom prices, and authoritative amounts without clearing the cache. (
Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricingKey.swift:18, 6a26b2e9b1b6) - Existing threshold tests define the expected pattern: CostUsagePricingTests already verifies that a bundled GPT threshold overrides the catalog's legacy 200K field. Astra tests cover full-request boundary pricing and reading persisted request rows. These provide focused seams for a GPT-6.1 Sol regression. (
Tests/CodexBarTests/CostUsagePricingTests.swift:725, 6a26b2e9b1b6)
Likely related people:
- Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
- urda: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
How this review workflow works
- ClawSweeper keeps one durable marker-backed review comment per issue or PR.
- Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
- A fresh review can be triggered by eligible
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch. - PR/issue authors and users with repository write access can comment
@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto request a fresh review only. - Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
- Maintainer-only repair and merge flows require explicit commands such as
@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review. - Maintainers can comment
@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.
Fixed by #4312 via the merge train #4317 (d919d238). The effective context threshold now comes from the models.dev explicit context tier (272,000 for the GPT-6 family) or the documented bundled fallback, and it participates in cache repricing; your 210,000-token example prices at standard rates. Thanks @wallmage. Ships in the next release.