Integrate models.dev pricing flow#884
Conversation
|
Pushed a small test-only CI fix in 59a1ad7: precompute the pricing expectations so Swift does not time out type-checking |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 680561a4a3
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let cost = currentPricingCost | ||
| ?? (cachedCost > 0 ? Double(cachedCost) / costScale : nil) |
There was a problem hiding this comment.
Preserve per-request threshold costs for Claude rows
This now prioritizes currentPricingCost over cachedCost, but currentPricingCost is computed from day/model aggregates instead of original per-request usage. For Claude models with long-context threshold pricing, aggregating many sub-200k requests can incorrectly cross the 200k tier and overstate cost (or understate in other mixes). Before this change, cached nanos preserved per-request pricing behavior, so this introduces report inaccuracies whenever threshold-priced models are used multiple times in a day.
Useful? React with 👍 / 👎.
| let currentPricingCost = self.computedCostUSD( | ||
| provider: provider, | ||
| modelName: modelName, | ||
| usage: packed, | ||
| pricingContext: pricingContext) |
There was a problem hiding this comment.
Avoid re-rating aggregated Pi usage with tiered pricing
computedCostUSD is being re-run on the aggregated packed totals for each model/day, which loses per-message boundaries needed for correct tiered Claude pricing. If multiple requests are each below the long-context threshold, recomputing on the sum can apply above-threshold rates that never actually occurred per request. The prior behavior used accumulated packed.costNanos from parse-time samples and did not introduce this aggregation error.
Useful? React with 👍 / 👎.
Summary
Reasoning
Scope
Screenshots
N/A
GIFs
N/A
References
Validation
swift test --filter CostUsagePricingTests --filter PiSessionCostScannerTests --filter CostUsageScannerTestsmake check./Scripts/compile_and_run.shAudit