Skip to content

fix(billing): preserve text tool surcharges in tiered settlement - #4162

Merged
Calcium-Ion merged 2 commits into
QuantumNous:nightlyfrom
yyhhyyyyyy:fix/tiered-text-tool-surcharge
Apr 23, 2026
Merged

fix(billing): preserve text tool surcharges in tiered settlement#4162
Calcium-Ion merged 2 commits into
QuantumNous:nightlyfrom
yyhhyyyyyy:fix/tiered-text-tool-surcharge

Conversation

@yyhhyyyyyy

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

修复 nightly 分支中文本计费路径中 tiered_expr 结算会覆盖工具附加费用,导致遗漏计费
当前逻辑里,calculateTextQuotaSummary() 会先把 web_search_preview、web_search、file_search、image_generation_call 等工具调用费用累加到 summary.Quota。但在 PostTextConsumeQuota() 中,如果 TryTieredSettle() 成功,代码会直接用 tieredQuota 覆盖 summary.Quota,导致这些按次附加费用被丢弃,最终实际结算额度偏低。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

@coderabbitai

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • alpha

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ff3773ce-7604-4074-b342-e3bc1d37eacb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…r path

Remove the intermediate branch that recomputed quota from
EstimatedQuotaBeforeGroup when tieredResult is nil. This discarded the
FinalPreConsumedQuota fallback that TryTieredSettle already selected.
Now the error path simply adds tool surcharges to the passed-in
tieredQuota, preserving the existing fallback semantics.

Also removes unrelated mise.toml and adds a test covering the error
fallback with a pre-consumed quota that differs from the estimate.
@Calcium-Ion
Calcium-Ion merged commit 55b7e48 into QuantumNous:nightly Apr 23, 2026
1 check passed
Jinxuans referenced this pull request in TokFlux-Org/TokFlux May 9, 2026
fix(billing): preserve text tool surcharges in tiered settlement
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.

2 participants