Repository navigation
Conversation
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Summary
Pre-merge checks:
|
Review statusThanks for contributing. This comment tracks the review sequence and the next action. Current step: Resolve the merge conflicts. The review sequence resumes after the branch is mergeable. Review-state labels are managed by this workflow; do not edit them manually. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
This PR has been awaiting author changes for 14 days and will be automatically closed in 7 days. Please address the review comments or leave a comment if you need more time. |
|
Closing due to author inactivity after requested changes. Feel free to reopen once the requested changes have been addressed. |
Related GitHub Issue
Closes: #1727
Description
For Anthropic and MiniMax models, the task cost shown in the UI omits the output-token portion of the bill, because the streaming loop never adopts the cumulative
message_delta.usage.output_tokensinto the local accumulator used for the finaltotalCostchunk — only themessage_startseed (0/1) is counted.This PR adopts the cumulative value (replace, not add — the final
message_deltacarries the message total, per the pinned SDK's replace semantics) in bothsrc/api/providers/anthropic.tsandsrc/api/providers/minimax.ts, so the end-of-stream cost chunk reflects the real output tokens. (opencode-go.tsalready documents this exact trap;anthropic-vertex.tsnever emits atotalCostchunk and is unaffected.)Test Procedure
message_startusage{input:100, output:1}+message_deltausage{output_tokens:500}→ final usage chunk'stotalCostequalscalculateApiCostAnthropic(info, 100, 500), not the starved(info, 100, 1). Verified failing before the fix, passing after.vitest run api/providers/__tests__/anthropic.spec.ts api/providers/__tests__/minimax.spec.ts→ 99/99.pnpm run test:coverage:core→ exit 0 (162 files / 3015 passed).vitest run --coverage --config vitest.api.config.ts→ exit 0; changed lines covered (anthropic.ts:295, minimax.ts:153).pnpm run check-types→ 0 errors. ESLint on changed files → clean, suppression counts unchanged.Pre-Submission Checklist
Visual Snapshots
N/A.
Videos (interaction / animation only)
N/A.
Documentation Updates
Additional Notes
Pre-existing (out of scope): the consumer in
Task.tssums the cumulative delta yield into its own display accumulator, so displayedtokensOutcan read ~1 over — cosmetic; the cost figure this PR fixes is now exact.Get in Touch
GitHub: @myk1yt — please tag me here; I monitor notifications.