Skip to content

fix(cost): report context-aware estimate ranges - #926

Merged
zcrab-oai merged 2 commits into
mainfrom
codex/context-cost-ranges
Sep 14, 2026
Merged

zcrab-oai merged 2 commits into
mainfrom
codex/context-cost-ranges

Conversation

@zcrab-oai

@zcrab-oai zcrab-oai commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Scan usage does not identify which requests received long-context pricing, but cost reports show a single short-context amount. Report a Standard token-cost range with explicit assumptions.

Changes

  • Add optional estimatedUsdRange and saved long-context rates. Widen the upper estimate when cache-write counts are incomplete; leave it unavailable when long-context rates are unverified.
  • Use shared range formatting in CLI summaries, progress, diagnostics, policy output, and dashboards. Preserve ranges through policy totals, JSON, and scan history.
  • Keep estimatedUsd and every spending-limit comparison unchanged. Read legacy costs without repricing them.
  • Document the additive result fields and cover pricing, missing usage, serialization, history, and budget display.

Testing

  • Context-pricing and existing pricing-property tests: 18 passed.
  • Result tests: 8 passed. Scan-history Python tests: 30 passed.
  • Type checks, formatting, plugin Ruff checks, plugin source checks and their 9 tests: passed.
  • Full SDK runs completed with fixed and fresh random seeds across 3,072 tests in 141 files. The final-tree run had 3,010 passed, 59 skipped, and 3 local environment failures.
  • All 3 environment failures passed focused reruns using writable test state, process-inspection access, or standard Git. The local Git-wrapper failure also reproduced on unchanged main.
  • The earlier full run exposed 2 outdated budget-error assertions; both were corrected, and all 4 targeted budget regression cases passed.
  • Two independent review passes and the follow-up review: no actionable findings.
  • GitHub platform checks passed except for an unrelated macOS authentication-test timeout. That test passed in both local full runs; the failed CI job is being rerun.

Risk and rollout

Reporting-only change: no billing, token-accounting, request execution, or spending-limit behavior changes. Existing consumers can keep reading estimatedUsd; cost reporting should use estimatedUsdRange. A null maximum means the upper estimate is unavailable. These bounds use Standard token prices and exclude other processing tiers, fees, surcharges, and account-specific pricing. No database migration or new CLI flags.

Rates were checked against the official price table and GPT-5.5 model documentation on September 14, 2026.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-14T19:12:43.127225Z 29a46ad New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the bug Something isn't working label Sep 14, 2026
@zcrab-oai
zcrab-oai merged commit 7b77956 into main Sep 14, 2026
136 of 143 checks passed
@zcrab-oai
zcrab-oai deleted the codex/context-cost-ranges branch September 14, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants