Skip to content

fix(core): prefer provider-reported usage cost - #41933

Open
rekram1-node wants to merge 3 commits into
v2from
reported-usage-cost
Open

fix(core): prefer provider-reported usage cost#41933
rekram1-node wants to merge 3 commits into
v2from
reported-usage-cost

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Summary

  • add an optional provider-reported USD cost to normalized AI usage
  • pass OpenRouter streamed usage.cost through the OpenAI-compatible parser
  • normalize GitHub Copilot total_nano_aiu to USD inside the Core AI SDK boundary
  • prefer valid reported costs in session accounting while retaining catalog pricing as fallback
  • carry reported cost through normal steps, title generation, and compaction

Details

  • packages/ai only knows the normalized optional USD cost; Copilot billing units remain isolated to Core
  • valid zero cost is authoritative
  • missing, negative, NaN, or infinite cost falls back to token-derived catalog pricing

Testing

  • bun typecheck from packages/ai
  • bun typecheck from packages/core
  • 51 focused Core tests across AI SDK conversion, usage accounting, runner settlement, title, and compaction
  • focused OpenRouter streamed-cost test
  • full monorepo pre-push typecheck: 32/32 tasks

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant