fix(antigravity): retry excluded accounts via fallback LRU - #5222
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances logging, tracking, and fallback logic for the 'antigravity' provider's connections, specifically handling Gemini family-level lockouts and cooldowns, and adds corresponding unit tests. The reviewer suggested simplifying the fallback scenario check in the round-robin strategy, pointing out that checking excludeConnectionId !== null is redundant since excludedConnectionIds already incorporates it.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const isFallbackScenario = excludeConnectionId !== null; | ||
| // If excluding account(s) (fallback scenario), skip sticky logic and go straight to LRU. | ||
| // This prevents same-model retries from getting stuck on a failed account. | ||
| const isFallbackScenario = excludeConnectionId !== null || excludedConnectionIds.size > 0; |
There was a problem hiding this comment.
Since excludedConnectionIds is constructed using normalizeExcludedConnectionIds(excludeConnectionId, options.excludeConnectionIds), it is guaranteed to already contain excludeConnectionId (if it is a valid non-empty string). Therefore, checking excludeConnectionId !== null is redundant when excludedConnectionIds.size > 0 is checked. We can simplify this expression to just excludedConnectionIds.size > 0.
| const isFallbackScenario = excludeConnectionId !== null || excludedConnectionIds.size > 0; | |
| const isFallbackScenario = excludedConnectionIds.size > 0; |
Treat accumulated excludedConnectionIds as account fallback mode so same-model Antigravity retries walk non-excluded eligible accounts instead of returning to sticky selection. Add safe candidate logging and Antigravity-family inferred cooldown coverage without changing global OAuth cooldown.
…ion guard; extract inferred cooldown constant The v2 multi-exclude test left only one eligible account, so sticky and LRU both picked it — it passed with or without the fallback change. Rewritten with two non-excluded accounts whose lastUsedAt diverge, so it fails without the `excludedConnectionIds.size > 0` fallback trigger and passes with it. Also extracts the inferred 30s antigravity-family 429 base to a named constant and documents that real upstream Retry-After hints still win via exactCooldownMs. Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
7d07296 to
3bda790
Compare
|
Thanks @Ardem2025! Rebased onto the current release tip and merging. Two adjustments before merge (co-authored):
The fallback LRU change correctly never re-selects excluded/terminal accounts (they're filtered out of |
6f150cf
into
diegosouzapw:release/v3.8.40
… gates Review fixes on top of the impersonation-UA refresh: - perplexity-web.ts: revert the Firefox UA bump 152 -> 148. The perplexity TLS profile is firefox_148 (no firefox_152 profile exists in the TLS client), and a UA-vs-JA3 mismatch is itself a Cloudflare bot signal (diegosouzapw#2459). The UA must stay matched to the TLS fingerprint we actually send. - translate-path golden snapshot: regenerate so the committed snapshot tracks the real output (the hand-edited copy still had the stale Cursor/3.3 UA; cursorVersionDetector now emits Cursor/3.9). - file-size baseline: rebaseline grok-web (1871->1873), muse-spark (1284->1302), perplexity-web (1013->1032) — the growth is unavoidable Prettier reflow that lint-staged applies to these grandfathered long-line files on any touch; the net semantic change is one UA constant each. Also reconcile auth.ts (2336->2401), a diegosouzapw#5222 antigravity-LRU growth that merged via --admin without a baseline bump. Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
… gates Review fixes on top of the impersonation-UA refresh: - perplexity-web.ts: revert the Firefox UA bump 152 -> 148. The perplexity TLS profile is firefox_148 (no firefox_152 profile exists in the TLS client), and a UA-vs-JA3 mismatch is itself a Cloudflare bot signal (diegosouzapw#2459). The UA must stay matched to the TLS fingerprint we actually send. - translate-path golden snapshot: regenerate so the committed snapshot tracks the real output (the hand-edited copy still had the stale Cursor/3.3 UA; cursorVersionDetector now emits Cursor/3.9). - file-size baseline: rebaseline grok-web (1871->1873), muse-spark (1284->1302), perplexity-web (1013->1032) — the growth is unavoidable Prettier reflow that lint-staged applies to these grandfathered long-line files on any touch; the net semantic change is one UA constant each. Also reconcile auth.ts (2336->2401), a diegosouzapw#5222 antigravity-LRU growth that merged via --admin without a baseline bump. Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
…apw#5222) Antigravity: retry excluded accounts via fallback LRU + family-inferred 429 cooldown. Test strengthened into a real LRU regression guard; cooldown constant extracted. Integrated into release/v3.8.40.
Summary
Builds on the family-scoped Antigravity lockout work in #5180 / release v3.8.39.
The combo same-model retry loop accumulates excluded Antigravity connection ids after account-level failures, but the auth selection path only treated
excludeConnectionId !== nullas a fallback scenario. Once retries accumulated exclusions throughexcludedConnectionIds, selection could fall back to normal sticky/priority behavior instead of LRU-selecting the next eligible account for the same model/family.This patch treats any non-empty accumulated exclude set as fallback mode:
and adds safe telemetry for the retry decision:
excluded_countpicked_lruactive,excluded,modelLocked,familyLocked,eligibleIt also keeps forced/pinned
connectionIdbehavior unchanged: same-model account retry is still gated to Antigravity combo requests without a forced connection id.While rebasing onto
release/v3.8.39, the new test also caught thatgetQuotaScopeLabelForProvider(...)was referenced insrc/sse/services/auth.tswithout being imported. This branch includes the minimal import fix so the family-lockout path does not fail at runtime.Test plan
node --import tsx --import ./open-sse/utils/setupPolyfill.ts --import ./tests/_setup/isolateDataDir.ts --test tests/unit/auth-antigravity-account-retry-v2.test.tsnpx eslint src/sse/services/auth.ts tests/unit/auth-antigravity-account-retry-v2.test.tsnode --import tsx --import ./open-sse/utils/setupPolyfill.ts --eval "await import('./src/sse/services/auth.ts'); console.log('auth_import_ok')"npm run typecheck:core