Repository navigation
feat(usage): fast-tier pricing and cost breakdown (upstream G7) - #1001
Merged
Merged
Conversation
Records carry a billing speed (standard/fast/ultrafast) instead of a fast flag. Codex rollouts now attribute the thread service tier, and rates read LiteLLM priority/ultrafast tiers alongside the Claude fast multiple. The scan cache moves to v5 in its own file; v3/v4 Codex history is kept and live rollouts are fully re-parsed via Pylon's pending-rescan flag. Pylon adaptations: OpenCode and Antigravity readers record standard speed; no Cursor reader or rateModel (not in Pylon); v3 migration retained. (cherry picked from commit 56914128c1ff9dcf6585c380b7b25845d6ca5f98) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Usage buckets gain optional categoryCostUsd, fastCostUsd, ultrafastCostUsd and speedPremiumUsd (contract version unchanged; older clients ignore them, older servers merge as unsplit standard cost). The web page adds cost/token share bars, a cost-by-speed bar with the premium, a ranked model table, and a per-model dialog with Set price; mobile adds a Cost section. Pylon adaptations: no Cursor rateModel or summary rows; Pylon's environment filter (approximate environments, source warnings) is kept and the price dialog lifts to the page; mobile segment logic is extracted to usageCostMix with tests; docs keep Pylon's provider list. (cherry picked from commit e8545b293b79cdd73d30ef921db149ef1b5abee0) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
The per-model dialog filtered only provider-wide buckets, but v7+ servers also send per-source buckets that the merge prefers, so it showed whole-page totals. narrowUsageSummary filters both. The Set price prefill now yields to an existing override after prices load instead of deciding once at mount, and the speed bar notes that older servers count all cost as Standard. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 3, 2026
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
Ports upstream group G7: Codex Fast/Ultrafast pricing, plus a cost breakdown by token type, speed and model. The change is adapted onto Pylon's diverged
apps/server/src/usage. All Pylon readers (OpenCode Go/local, Antigravity, cliproxy), price overrides, settings and the v3 scan-cache migration are kept.Sources
56914128c1fix(usage): Codex Fast and Ultrafast now cost what they bill-x.UsageRecord.fastbecomesspeed: standard/fast/ultrafast. The Codexthread_settings_applied.service_tiervalue is tracked. Rates read LiteLLM*_priority/*_ultrafasttiers alongside the Claudeprovider_specific_entry.fastmultiple. The scan cache moves to v5 in its own file,usage-scan-cache-v5.json, and the legacy file is read once.e8545b293bfeat(usage): show cost by token type, speed, and model detail-x. Optional bucket fields are added.mergeUsagegainscategoryCost,speedCost,ModelTotals.tokensandunpricedTokens. Web gets share bars, a ranked model table, a per-model dialog and a Set price entry point. Mobile gets a Cost section.Pylon adaptations
speed: "standard". The upstreamcursorUsageReader.tsand therateModel/ Cursor pricing tests were dropped because Pylon has no Cursor usage reader. Cursor summary rows were not adopted for the same reason.frpending-rescan flag) is kept and extended:needsFastRescan, so a live rollout is fully re-parsed before it is served warm again. Upstream used asize: -1sentinel instead.model-manifest.jsoncarries no prices, so the Fast/Ultrafast premiums come from the LiteLLM rate table, as upstream does. Custom price overrides apply at every speed (unchanged).usageCostMix.tswith unit tests. Upstream had it inline.docs/user/usage.mdkeeps Pylon's provider list and wording. Only the new breakdown and Set-price sentences were added.USAGE_CONTRACT_VERSIONstays at 8. All new bucket fields areSchema.optional. Older clients ignore them, and the merge treats buckets from older servers as unsplit standard cost.Review fixes (
c1230f7ab9)summary.bucketslist, but v7+ servers also send per-source buckets, and the merge reads those instead. NewnarrowUsageSummary(inpackages/shared/usageMerge.ts) filters both. Regression tests use per-source buckets inusageMerge.test.tsandstate/usage.test.tsx: models a ($1) and b ($5) filtered to a now give $1 and[a].withoutSupersededPrefill). An untouched prefill yields to an existing override once prices load. Typed rates are never dropped. Tested inusagePriceTable.test.ts.Verification
vp test run src/usage(apps/server): 11 files, 143 tests passed.vp test run src/usageMerge.test.ts(packages/shared): 46 passed.vp test run src/state/usage.test.tsx src/components/usage(apps/web): 11 files, 89 passed.vp test run src/features/usage(apps/mobile): 5 files, 12 passed.tsc --noEmit:@t3tools/contracts,@t3tools/shared,@t3tools/web,@t3tools/mobileandt3all passed.vp lintandvp fmt --checkon the changed files: formatting is clean. The only lint output is 3 warnings that already exist onpylon(an unusedlayerTestinUsageService.ts, and unuseduseRef/useStateinstate/usage.ts).Not verified
usage-scan-cache.json. A v5 server reads that file only when its own file is missing, which is the intended upstream design.Part of upstream cycle #996.
🤖 Generated with Claude Code