Repository navigation
fix: accept scalar provider costs across response codecs - #1576
Merged
willkill07 merged 2 commits intoOct 29, 2026
Merged
Conversation
Signed-off-by: Will Killian <[email protected]>
Contributor
Contributor
I take it back ❌ Need to update tests with old contract |
Signed-off-by: Will Killian <[email protected]>
greysonlalonde
approved these changes
Oct 29, 2026
This branch was previously deployed
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.
Overview
Preserve response annotations when OpenAI Responses or Anthropic Messages upstreams return a numeric
usage.cost, as OpenRouter does. Numeric costs are recorded as provider-reported USD totals.Details
cost_usdprecedence and detailed cost currency/component handling.usage.costvalues so token usage, response text, and finish reasons remain available.Validation:
just test-rust: 6,599 passed, 4 skipped before updating the branch base to the latestrelease/0.11.cargo-denyhook failed while parsing the local advisory database (failed to find toml block); only that hook was skipped when committing.just test-python-google-adk: 566 passed, including annotation retention for unrecognized cost and the separate invalid-usage failure path. Other binding suites were not rerun locally.Where should the reviewer start?
Start with
crates/core/src/codec/response.rsfor shared cost decoding, thencrates/core/tests/unit/codec/response_tests.rsfor numeric, detailed, malformed, and precedence cases.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
usage.cost, dropping the whole response annotation #1573Summary by CodeRabbit
usage.costvalues for OpenAI Chat, OpenAI Responses, and Anthropic Messages. When available,cost_usdtakes precedence overusage.cost.