Skip to content

fix(provider): honor per-model reasoning token pricing#24233

Closed
willsarg wants to merge 1 commit into
anomalyco:devfrom
willsarg:upstream/fix/reasoning-token-pricing
Closed

fix(provider): honor per-model reasoning token pricing#24233
willsarg wants to merge 1 commit into
anomalyco:devfrom
willsarg:upstream/fix/reasoning-token-pricing

Conversation

@willsarg
Copy link
Copy Markdown

Issue for this PR

Closes #24231

Type of change

  • Bug fix

What does this PR do?

Addresses the TODO in Session.getUsage that hardcoded reasoning tokens at the output rate. Adds an optional reasoning price to the cost schemas (config/provider.ts, provider/models.ts, provider/provider.ts), threads it through the user-override merge, and uses it in getUsage with the output rate as fallback.

Backward compatible — when cost.reasoning is absent, behavior is unchanged.

How did you verify your code works?

Two tests in compaction.test.ts: one asserting reasoning tokens are charged at cost.reasoning when set, one guarding the fallback path. bun test test/session/compaction.test.ts passes, bun typecheck clean.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Plumbs an optional reasoning field through the cost schemas (models.dev
config, provider schema, user-config override merge) and uses it in
Session.getUsage, falling back to the output rate when unset.

This addresses the TODO comment next to the old
  new Decimal(tokens.reasoning).mul(costInfo?.output ?? 0)
which was hardcoding reasoning tokens at the output rate. Backward
compatible: when no reasoning cost is defined the behavior is unchanged.
@github-actions
Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reasoning tokens are charged at the output rate regardless of the model's reasoning price

1 participant