Repository navigation
fix: limit: 0 的冷却改为递增退避,不再等 RetryDelay - #65
Closed
swdswd2401999-ops wants to merge 1 commit into
Closed
swdswd2401999-ops wants to merge 1 commit into
swdswd2401999-ops wants to merge 1 commit into
Conversation
zeroQuotaLimit() 已把这类 429 标成「无配额」,说明代码识别出它不是 额度用完而是账号没有该模型的访问权限。但 until 仍取自 RetryDelay, 于是每次都是:冷却 19 小时 → 到点重试 → 又是 limit: 0 → 再等 19 小时。 实测依据: - 9/9 条 retry in 精确指向 UTC 零点(如 04:49:51 + 19h10m8s = 次日 00:00:00) - 次日同一模型同一账号仍是 limit: 0,等多久都不恢复 - 只有 4%(7/156)的 argon 请求受影响,因为系统会自动回退 playground 改为走已有的 planLimitBackoff(1m → 5m → 15m → 30m → 1h): - 权限若真开通,一小时内就能发现,而不是等 19 小时 - 若没开通,代价是每小时一次失败探测(约 60ms,不占并发槽) - 复用 planLimitCooldown 的 Level 递增逻辑,不改动其他分支 测试:internal/aistudio/quota_zerolimit_test.go 覆盖 8 种情形 (limit:0 / limit:100 / 混合 / 无 limit 字段 / 递增 / 封顶 / 冷却未过期 / global 标记)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
问题
zeroQuotaLimit()已经把「所有额度项都报limit: 0」的 429 标成kind = "无配额",说明代码识别出这不是额度用完,而是账号没有该模型的访问权限。但
until仍然取自RetryDelay:于是每次都是:冷却 19 小时 → 到点重试 → 又是
limit: 0→ 再等 19 小时。既然已经判定「不是额度问题」,就不该沿用「额度日重置」的时间。
实测依据
从生产日志里提取全部 9 条
retry in,加上报错时刻后:9/9 条精确指向 UTC 零点(±10 秒),也就是说上游给的
retry in本身就是「到下一个额度日」。但次日同一模型同一账号仍然是
limit: 0:因为这是权限问题,不是额度问题 —— 等多久都不会变。
改动
kind == "无配额"时提前返回,Escalate: true让MarkQuotaCooldownIfGeneration走已有的planLimitCooldown分支:planLimitBackoff已经是1m → 5m → 15m → 30m → 1h,planLimitCooldown会读上一次的Level递增,不用新增任何逻辑。取舍
代价是权限长期不开通时每小时多一次失败探测。实测这类失败约 60ms(
ProxyUnaryCall直接被 429 拒绝),不占并发槽,也远小于「每天干等 19 小时」。影响面
只改
无配额分支。limit: 100这类真额度用完仍按RetryDelay恢复(TestRealQuotaStillUsesRetryDelay覆盖)。limit里有任一非零值时不判为无配额(TestMixedLimitIsNotZeroQuota),没有limit字段时也不误判(TestNoLimitTokenIsNotZeroQuota)。测试
新增
internal/aistudio/quota_zerolimit_test.go,8 个用例:线上验证
在生产实例上换成自编译二进制后:
改前同一字段是
剩余 12.6h level=None。备注
关于
gemini-4-argon在 Build 通道的limit: 0,issue #59 里提到这是 Google 曾把前端配置错、让 free 用户也能用 Ultra 专属模型。这个改动不试图绕过权限限制 —— 只是让「已知无权限」的冷却时长与它的真实恢复方式匹配。