fix(antigravity): clamp upstream retryDelay/reset to prevent excessive cooldowns#2302
Open
ryneivy wants to merge 1 commit into
Open
fix(antigravity): clamp upstream retryDelay/reset to prevent excessive cooldowns#2302ryneivy wants to merge 1 commit into
ryneivy wants to merge 1 commit into
Conversation
…e cooldowns Antigravity occasionally returns very long retry windows (hours or days, e.g. on geo-restricted accounts or true quota exhaustion). The gateway currently propagates these values verbatim to SetModelRateLimit / SetRateLimited, locking accounts out of scheduling for the full duration. Mirror the OpenAI fix from Wei-Shaw#2290 by capping the value at a local upper bound: - Add antigravityMaxRateLimitCooldown = 2h (same magnitude as OpenAI's maxRateLimit429CooldownSeconds = 7200). - Apply the cap in two places that consume upstream-supplied wait time: - parseAntigravitySmartRetryInfo: clamps retryDelay parsed from google.rpc.RetryInfo (covers smart-retry and "switch account" paths). - (*AntigravityGatewayService).resolveResetTime: clamps the absolute reset timestamp used by the 429 fallback handler. - Log a single line when a clamp fires, so operators can spot pathological upstream responses. Out of scope, intentional: - Account-recovery hook analogous to recoverOpenAIRateLimitedAccountBeforeNoAvailable (touches the shared selector path; left for a follow-up PR). - antigravityRateLimitThreshold / antigravitySmartRetryMaxAttempts. Tests added in antigravity_cooldown_clamp_test.go cover both helpers and verify parseAntigravitySmartRetryInfo clamps a 24h retryDelay while leaving short delays (0.4s) untouched.
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.
Antigravity occasionally returns very long retry windows (hours or days, e.g. on geo-restricted accounts or true quota exhaustion). The gateway currently propagates these values verbatim to SetModelRateLimit / SetRateLimited, locking accounts out of scheduling for the full duration.
Mirror the OpenAI fix from #2290 by capping the value at a local upper bound:
Out of scope, intentional:
Tests added in antigravity_cooldown_clamp_test.go cover both helpers and verify parseAntigravitySmartRetryInfo clamps a 24h retryDelay while leaving short delays (0.4s) untouched.