You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
当 Grok Build 账号额度耗尽时,上游可能返回:
响应体包含:
{ "code": "personal-team-blocked:spending-limit", "error": "You have run out of credits or need a Grok subscription." }网关原先将
X-Should-Retry: false解释为禁止整个请求继续重试,因此会直接将 402 返回给客户端,不会尝试账号池中的其他可用账号。这会导致单个账号额度耗尽阻断整个请求,即使账号池中仍有额度正常且支持当前模型的账号。
根因
X-Should-Retry描述的是是否应该重试当前上游账号,但现有isRetryableResponse将它作为账号池级别的全局重试否决条件。对于
personal-team-blocked:spending-limit,重试同一个账号没有意义,但切换到其他账号仍然可以成功处理请求。此外,当上游已经明确确认额度耗尽,而本地 Billing 快照没有可靠的账期结束时间时,现有逻辑无法通过
MarkPaidQuotaExhausted将该账号移出路由池。账号可能很快再次被选中,并继续影响其他会话。修改内容
402 Payment Required保留跨账号故障转移能力,即使响应包含X-Should-Retry: false。403、429和5xx响应仍继续遵守上游的X-Should-Retry: false,避免扩大重试范围。行为说明
402 + spending-limit + X-Should-Retry:false403/429/5xx + X-Should-Retry:false兼容性
403、429和5xx的上游重试语义。402响应。测试
新增回归测试覆盖:
X-Should-Retry: false。402不会被该响应头阻止跨账号故障转移。personal-team-blocked:spending-limit后,请求由第二个账号成功处理。已执行:
相关 gateway 测试、vet 和 diff 检查均通过。