Repository navigation
fix(antigravity): 无重置时间的裸 429 只冷却失败的模型 / Cool only the failed model on a bare 429 - #8836
Open
Oracle0703 wants to merge 1 commit into
Open
Oracle0703 wants to merge 1 commit into
Oracle0703 wants to merge 1 commit into
Conversation
A 429 without quotaResetDelay or RetryInfo does not show that the shared Gemini quota is exhausted: the upstream also returns this body for requests it rejects by content (Wei-Shaw#8824). The 429 fallback in handleUpstreamError still wrote the antigravity:gemini family key, so one rejected request made every Gemini model on the account unschedulable until the cooldown ended. When no reset time can be parsed, cool only the failed model. 429s with quotaResetDelay, RetryInfo, "Please retry in" or a daily quota, and the RATE_LIMIT_EXCEEDED smart-retry paths, still write the family key. Refs Wei-Shaw#8824 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
All contributors have signed the CLA. ✅ |
doublepi123
added a commit
to doublepi123/sub2api
that referenced
this pull request
Nov 17, 2026
Port upstream Wei-Shaw#8836. A 429 without quotaResetDelay / RetryInfo does not prove the shared Gemini quota is exhausted (content-based rejections look identical), so it now cools only the failed model key instead of also writing the antigravity:gemini family key. One rejected request no longer turns every other Gemini model on the account into 503 "No available accounts" for a minute. 429s that carry a reset time keep the family scope. The ported tests expect the key the fork actually cools: since the Claude 5.5 / Hydrogen port, cooldowns are keyed on the forwarded variant (gemini-3.8-flash resolves to gemini-3.8-flash-high).
Author
|
recheck |
Warren-W
pushed a commit
to Warren-W/sub2api
that referenced
this pull request
Nov 20, 2026
…ool only the failed model on a bare 429 Upstream PR: Wei-Shaw#8836 (squashed from a831b21)
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.
Refs #8824(issue 里的建议 3)。#8829 删掉了这次触发 429 的句子,但没有改冷却范围;本 PR 只改冷却范围。
问题
上游对按内容拒绝的请求也会返回裸 429:
Resource has been exhausted (e.g. check quota).,不带quotaResetDelay/RetryInfo。handleUpstreamError的 429 兜底分支在这种情况下使用默认冷却时长,并且同时写入模型 key 和家族 keyantigravity:gemini(Pro 账号的 Argon 是antigravity:gemini:argon)。结果一个请求被拒,同账号的所有 Gemini 模型都要等冷却结束,期间无关请求返回503 No available accounts。改动
只改
handleUpstreamError的 429 兜底分支:如果响应里解析不出重置时间(ParseGeminiRateLimitResetTime返回 nil),就只冷却失败的那个模型 key,不写家族 key。冷却时长不变。日志model_rate_limited增加keys=字段,便于确认写了哪些 key。下面这些情况不变,仍然写家族 key:
quotaResetDelay、RetryInfo.retryDelay、Please retry in Xs或按天配额的 429;RATE_LIMIT_EXCEEDED的智能重试路径(handleSmartRetry、handleModelRateLimit、handleAntigravityModelRateLimitBeforePolicy)。图片模型和 Claude 模型本来就不写家族 key,不受影响。
取舍:如果某个裸 429 其实是整个 Gemini 配额池耗尽,同账号的其他 Gemini 模型各会多失败一次,然后再各自冷却。失败的模型本身仍按原时长冷却,所以不会回到 #2902 那种反复调度同一账号的情况。
验证
backend/internal/service/antigravity_bare_429_scope_test.go:quotaResetDelay、RetryInfo、Please retry in三种带重置时间的 429 仍写家族 key,同族其他模型不可调度。go build ./...、go vet -tags=unit ./internal/service/、gofmt 通过。GOOS=linux下./internal/service/...0 issues。go test -tags=unit ./...(Windows):60 个包通过。internal/service有 3 个失败,都不涉及 Antigravity:TestOllamaProbeCallback_StaleLongDoesNotOverrideNewShort:在未修改的main@530c5e3a4上单独跑同样失败(fix(openai): preserve Codex standalone context on Responses #8680 也提到过 Windows 下复现);TestCommandCodeGatewayPassesThroughCatalogProtocols:在未修改的main@530c5e3a4上单独跑 10 次失败 6 次;TestOpenAIWSPassthroughFirstTokenFollowsTTFTMode:1.099s < 1.1s 的计时边界抖动;本次在未修改的main上单独跑通过,我们之前在同一份上游代码上复现过。未验证,请帮忙试一下
我们没有 Gemini / Antigravity 账号,没有对真实上游做过端到端验证。
@yanhexiong 方便的话,能否在 #8824 的环境里用这个分支试一下?本分支基于
main,没有包含 #8829,所以原来那个 Claude Code 请求应该仍会触发裸 429:model_rate_limited model=<模型> keys=<模型>,不再出现antigravity:gemini;503 No available accounts。是否合并由维护者决定。
🤖 Generated with Claude Code