Skip to content

fix(quota): stop resending requests to an account whose weekly window is empty - #112

Merged
JoshRob297 merged 1 commit into
mainfrom
fix/quota-busqueda-29-9
Nov 22, 2026
Merged

JoshRob297 merged 1 commit into
mainfrom
fix/quota-busqueda-29-9

Conversation

@JoshRob297

Copy link
Copy Markdown
Owner

Five defects from the audit, all in the quota and search path.

Weekly quota hidden by the five-hour window. fetchAccountQuotaDetails (quota.ts) stored only fiveHour in cachedQuota, so an account with weekly = 0% and fiveHour > 0% was picked again on every request: 429, mark in rateLimitResetTimes, same account again. It now keeps the minimum of both windows, and ALLOWED_PREFIXES covers 3.8 Flash, Argon and Claude 5.5, which used to get cachedQuota: {} from the fallback.

All Antigravity accounts failed after three empty bodies. The continue in the endpoint loop burned the three fallbacks without retrying, and the global emptyResponseAttempts map left the counter at 3, aborting the next request of the session. Now the loop retries the same endpoint, the counter is per request, and EmptyResponseError is propagated.

verifyAccountAccess pointed at PROD (429), used the retired Electron user agent and a model that no longer exists.

google_search used the obsolete user agent, the sandbox host without fallback or account rotation, and ignored thinking (missing from the v2 schema).

flush() emitted the synthetic usageMetadata chunk wrapped in { response: ... }, which the SDK parser discards.

Eleven new tests, including one where an account with weekly at zero must not be selected again. Suite: 48 files, 1222 tests.

… is empty

fetchAccountQuotaDetails saved only the five-hour window, so an account with weekly at 0% and fiveHour above it kept being selected: 429, a mark in rateLimitResetTimes, and the same account again on the next request. It now keeps the minimum of both windows, and the fetchAvailableModels fallback covers 3.8 Flash, Argon and Claude 5.5 instead of returning an empty cachedQuota.

Three empty responses in a row no longer end in 'All Antigravity accounts failed': the loop retries the same endpoint instead of burning the three fallbacks, the attempt counter is per request instead of a global map, and EmptyResponseError is propagated.

Also: verifyAccountAccess points at the fallback endpoint with the CLI user agent and a model that still exists; google_search uses the same user agent, honours thinking and rotates accounts; the synthetic usageMetadata chunk is emitted unwrapped.
@github-actions

Copy link
Copy Markdown

Automated verification

Check Result
typecheck success
tests success
build success
branch clean
typecheck

> opencode-antigravity-auth@2.9.9 typecheck
> tsc --noEmit

tests
2m�[2m135 tests�[22m�[2m)�[22m�[32m 50�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/request-helpers.test.ts �[2m(�[22m�[2m162 tests�[22m�[2m)�[22m�[32m 70�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/accounts.test.ts �[2m(�[22m�[2m117 tests�[22m�[2m)�[22m�[32m 75�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/transform/claude.test.ts �[2m(�[22m�[2m67 tests�[22m�[2m)�[22m�[32m 22�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/quota.test.ts �[2m(�[22m�[2m26 tests�[22m�[2m)�[22m�[32m 52�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/request.test.ts �[2m(�[22m�[2m114 tests�[22m�[2m)�[22m�[32m 115�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/rotation.test.ts �[2m(�[22m�[2m59 tests�[22m�[2m)�[22m�[32m 43�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/transform/model-resolver.test.ts �[2m(�[22m�[2m57 tests�[22m�[2m)�[22m�[32m 21�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/transform/cross-model-sanitizer.test.ts �[2m(�[22m�[2m28 tests�[22m�[2m)�[22m�[32m 14�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/storage.test.ts �[2m(�[22m�[2m22 tests�[22m�[2m)�[22m�[32m 19�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/config/model-discovery.test.ts �[2m(�[22m�[2m49 tests�[22m�[2m)�[22m�[32m 24�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/config/updater.test.ts �[2m(�[22m�[2m18 tests�[22m�[2m)�[22m�[32m 25�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/cross-model-integration.test.ts �[2m(�[22m�[2m14 tests�[22m�[2m)�[22m�[32m 8�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/persist-account-pool.test.ts �[2m(�[22m�[2m38 tests�[22m�[2m | �[22m�[90m25 todo�[39m�[2m)�[22m�[32m 12�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/stores/signature-store.test.ts �[2m(�[22m�[2m30 tests�[22m�[2m)�[22m�[32m 12�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/thinking-recovery.test.ts �[2m(�[22m�[2m29 tests�[22m�[2m)�[22m�[32m 9�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/cache.test.ts �[2m(�[22m�[2m25 tests�[22m�[2m)�[22m�[32m 20�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/search.test.ts �[2m(�[22m�[2m12 tests�[22m�[2m)�[22m�[32m 15�[2mms�[22m�[39m
 �[32m✓�[39m src/v2/adapter.test.ts �[2m(�[22m�[2m7 tests�[22m�[2m)�[22m�[32m 39�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin.test.ts �[2m(�[22m�[2m3 tests�[22m�[2m)�[22m�[32m 68�[2mms�[22m�[39m
 �[32m✓�[39m src/hooks/auto-update-checker/index.test.ts �[2m(�[22m�[2m11 tests�[22m�[2m)�[22m�[32m 21�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/usage-ledger.test.ts �[2m(�[22m�[2m7 tests�[22m�[2m)�[22m�[32m 11�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/version.test.ts �[2m(�[22m�[2m15 tests�[22m�[2m)�[22m�[32m 47�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/antigravity-first-fallback.test.ts �[2m(�[22m�[2m8 tests�[22m�[2m)�[22m�[32m 14�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/model-entitlements.test.ts �[2m(�[22m�[2m9 tests�[22m�[2m)�[22m�[32m 10�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/recovery.test.ts �[2m(�[22m�[2m30 tests�[22m�[2m)�[22m�[32m 10�[2mms�[22m�[39m
 �[32m✓�[39m src/hooks/auto-update-checker/checker.test.ts �[2m(�[22m�[2m12 tests�[22m�[2m)�[22m�[32m 34�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/auth.test.ts �[2m(�[22m�[2m19 tests�[22m�[2m)�[22m�[32m 11�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/refresh-queue.test.ts �[2m(�[22m�[2m4 tests�[22m�[2m)�[22m�[32m 6�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/quota-fallback.test.ts �[2m(�[22m�[2m10 tests�[22m�[2m)�[22m�[32m 198�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/debug.test.ts �[2m(�[22m�[2m6 tests�[22m�[2m)�[22m�[32m 16�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/header-timeout-retry.test.ts �[2m(�[22m�[2m10 tests�[22m�[2m)�[22m�[32m 34�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/safety.test.ts �[2m(�[22m�[2m5 tests�[22m�[2m)�[22m�[32m 30�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/errors.test.ts �[2m(�[22m�[2m16 tests�[22m�[2m)�[22m�[32m 7�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/stats.test.ts �[2m(�[22m�[2m4 tests�[22m�[2m)�[22m�[32m 38�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/ui/auth-menu.test.ts �[2m(�[22m�[2m12 tests�[22m�[2m)�[22m�[32m 17�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/model-specific-quota.test.ts �[2m(�[22m�[2m4 tests�[22m�[2m)�[22m�[32m 5�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/logging-utils.test.ts �[2m(�[22m�[2m7 tests�[22m�[2m)�[22m�[32m 20�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/core/streaming/safety-shield.test.ts �[2m(�[22m�[2m3 tests�[22m�[2m)�[22m�[32m 6�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/historical-pruning.test.ts �[2m(�[22m�[2m4 tests�[22m�[2m)�[22m�[32m 5�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/token.test.ts �[2m(�[22m�[2m3 tests�[22m�[2m)�[22m�[32m 26�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/ui/ansi.test.ts �[2m(�[22m�[2m13 tests�[22m�[2m)�[22m�[32m 6�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/config/tiered-families.test.ts �[2m(�[22m�[2m6 tests�[22m�[2m)�[22m�[32m 8�[2mms�[22m�[39m
 �[32m✓�[39m src/constants.test.ts �[2m(�[22m�[2m5 tests�[22m�[2m)�[22m�[32m 7�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/logger.test.ts �[2m(�[22m�[2m2 tests�[22m�[2m)�[22m�[32m 10�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/config/models.test.ts �[2m(�[22m�[2m5 tests�[22m�[2m)�[22m�[32m 4�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/config/schema.test.ts �[2m(�[22m�[2m4 tests�[22m�[2m)�[22m�[32m 6�[2mms�[22m�[39m
 �[32m✓�[39m src/plugin/empty-response-retry.test.ts �[2m(�[22m�[2m1 test�[22m�[2m)�[22m�[33m 1555�[2mms�[22m�[39m
   �[32m✓�[39m empty-response retry across endpoint fallbacks �[2m(1)�[22m
     �[33m�[2m✓�[22m�[39m keeps retrying the same endpoint until the fourth attempt instead of failing�[33m 1553�[2mms�[22m�[39m

�[2m Test Files �[22m �[1m�[32m48 passed�[39m�[22m�[90m (48)�[39m
�[2m      Tests �[22m �[1m�[32m1222 passed�[39m�[22m�[2m | �[22m�[90m25 todo�[39m�[90m (1247)�[39m
�[2m   Start at �[22m 20:50:57
�[2m   Duration �[22m 4.59s�[2m (tests 39%, import 31%, transform 25%, worker 5%)�[22m

�[2m    Isolate �[22m �[33m48 workers spawned�[39m�[2m · ~104ms startup each (spawn + environment, per file)�[22m
�[2m            �[22m �[2mat least ~1.57s faster with �[22m�[33misolate: false�[39m�[2m — reuses workers across files instead of one per file�[22m

build

> opencode-antigravity-auth@2.9.9 build
> tsc -p tsconfig.build.json

@JoshRob297
JoshRob297 merged commit 4674475 into main Nov 22, 2026
1 check passed
@JoshRob297
JoshRob297 deleted the fix/quota-busqueda-29-9 branch November 22, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant