Repository navigation
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
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:
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. |
Issue for this PR
Closes #35765
V2 issue linking: This PR targets
v2per its contribution guide. GitHub closing links only apply to the default branch (dev), so the standards workflow flags this existing reference. A maintainer needs to link #35765 manually in Development.Type of change
What does this PR do?
V2 currently discards Copilot's reported charge and estimates cost from catalog token prices. Add a dedicated
Usage.billedCostfield, branded as USD and restricted to finite nonnegative amounts.The AI SDK bridge requests Copilot raw chunks and reads
copilot_usage.total_nano_aiufrom Chat chunks or the nested Responses response. It uses the existing Copilot conversion of 100 billion nano AIU per USD, retains the latest valid charge per physical request, and emits it in normalized usage. Other providers' raw chunks remain unaffected.Session step settlement retains only that typed charge alongside normalized tokens, then prefers it over the catalog estimate for both successful and settled-failure steps. Zero is a valid reported charge; absent or malformed billing keeps the existing estimate. No arbitrary provider metadata is added to the step settlement.
How did you verify your code works?
test/aisdk.test.ts,test/session-runner.test.ts, andtest/session-runner-tool-events.test.ts; a subsequent shipped Copilot Chat decoder integration test also passes (53 total AISDK tests).bun test test/schema.test.ts— 23 passing tests.bun run check— lint and all 36 repository typecheck tasks pass. Core typecheck also passes with the additional integration test.Provider streams are fixture-driven; no live Copilot request or credentials are used.
Screenshots / recordings
N/A — billing normalization and persistence.
Checklist