feat: add exact Fast usage and tier-aware cost tracking#280
Merged
Conversation
douglasmonsky
marked this pull request as ready for review
July 17, 2026 02:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
response.completedevents incrementally and conservatively reconcile their exact service tiers to canonical usage callspriority,fast,standard,default,flex, and other observed tiers while deriving the Fast flag separatelyWhy
Codex session logs do not directly record whether a call used Fast mode. Existing throughput heuristics can identify candidates but cannot support exact historical accounting. Codex OTLP completion events contain the response service tier, so retained OTel evidence can identify exact Fast/Priority usage moving forward and reconstruct history only where those aggregate logs still exist.
Fast/Priority also has two distinct cost interpretations. ChatGPT usage may consume Codex credits with a documented Fast multiplier, while API usage may use the higher Priority processing token rates. This change models both without inferring the account's billing channel from routing evidence alone.
Billing semantics
usage_creditsremains a ChatGPT-equivalent credit estimate and applies a source-stamped Fast multiplier only to confirmed Fast calls.estimated_cost_usdremains an API-token-equivalent estimate and selects the exact observed API service-tier table when configured.billing_basisis an explicit local setting:unknown,chatgpt_credits, orapi_tokens.billing_basis.User impact
Validation
python -m pytest -p no:cacheprovider -q— 1,086 passedpython -m pytest -p no:cacheprovider --cov=codex_usage_tracker --cov-report=term -q— 1,086 passed, 88% coverageruff check --no-cache .python -m mypy --no-incrementalcodex-task dashboard-verify --jsonpython -m buildpython -m twine check dist/*python scripts/check_release.py --distgit diff --check