fix: skip estimated tokens for abnormal streams without usage (#4168)#6112
fix: skip estimated tokens for abnormal streams without usage (#4168)#6112cat0825 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughStreaming quota calculation now skips estimated prompt tokens when a stream ends abnormally without upstream usage. Billing metadata records the skipped deduction, while normal completed streams retain estimated usage. Tests cover both behaviors. ChangesStreaming quota handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Important
📝 变更描述 / Description
当流式请求异常结束(client_gone/timeout 等)且上游未返回 usage 时,不再使用估算 prompt tokens 结算扣费。正常结束或上游提供 usage 的路径保持不变,避免误伤。
This PR was AI-assisted and manually reviewed before submission.
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
Summary by CodeRabbit