[Bug]: Antigravity usage limits stay at 100% left after account switch and at 0% exhaustion (stale acp_token.json + cloudcode-pa backfill) #39828
Before submitting#
- I searched existing issues and did not find a duplicate covering all of these findings (related: #34381, #39607).
- I included enough detail to reproduce and investigate the problem.
Area#
apps/server (src/provider/antigravityUsageLimits.ts, src/provider/Drivers/antigravityUsageReader.ts)
Environment#
- T3 Code version:
0.1.10(Linux AppImage) - Antigravity ACP version:
1.5.13(default managed runtime under~/.t3/tools/antigravity-acp/linux-x64/...) - OS: Linux (Secret Service / OS keyring active)
- Auth method:
oauth-personal(Google AI Pro,project_id: aicode-consumers)
Summary#
T3 Code's Antigravity usage monitor stayed at 100% left even when the active Google account hit RESOURCE_EXHAUSTED (code 429): Individual quota reached on gemini-4-neon, and continued showing 100% left after burning additional millions of tokens in a new 5-hour window.
Inspecting the bundled server code and comparing live v1internal:retrieveUserQuotaSummary responses uncovered three concrete bugs:
Bug 1: Managed antigravity-acp 1.5.13 switches accounts in the OS keyring while antigravityUsageLimits.ts keeps polling a stale acp_token.json#
Related to #34381 (which describes switching binary path to agy CLI) and #39607 (which describes missing acp_token.json), this also happens on the default managed antigravity-acp 1.5.13 binary when a pre-existing acp_token.json is already on disk:
- Earlier login with Google Account A created
<stateDir>/providers/antigravity/<instance>/antigravity-acp/acp_token.json. - Logging out and signing into Google Account B via Antigravity ACP 1.5.13 updates the Linux OS keyring (
service="gemini",username="antigravity"— ACP log:ChainedAuth: authenticated via keyring (effective: keyring)), leaving the olderacp_token.jsonuntouched on disk. makeAntigravityUsageProbeinsrc/provider/antigravityUsageLimits.tsreadsacp_token.jsondirectly and never reads the keyring or clears/invalidates staleacp_token.jsonon logout/re-auth.- As a result, T3 polls Account A's untouched quota (
gemini-5h: remainingFraction=1,gemini-weekly: remainingFraction=1→100% left) while ACP is actively running on Account B (gemini-5h: remainingFraction=0.8298,gemini-weekly: remainingFraction=0.6624).
Bug 2: Proto3 0.0 omission + cloudcode-pa.googleapis.com merge backfills 100% left at exhaustion#
Even on the correct active account (Account B), daily-cloudcode-pa.googleapis.com and cloudcode-pa.googleapis.com return different quota states for v1internal:retrieveUserQuotaSummary:
https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary(where Antigravity ACP actually routes traffic):gemini-5h:remainingFraction: 0.8297706(83% left)gemini-weekly:remainingFraction: 0.6623908(66% left)
https://cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary(same token, sameproject: "aicode-consumers"):gemini-5h:remainingFraction: 1(100% left)gemini-weekly:remainingFraction: 1(100% left)
In src/provider/antigravityUsageLimits.ts:
quotaWindow()drops any bucket wherequota.remainingFraction === undefined:if (quota.remainingFraction === void 0 || !Number.isFinite(quota.remainingFraction)) return;- In Google's Proto3 JSON serialization,
remainingFraction == 0.0(quota exhausted) is the default scalar value and is omitted on the wire. fetchWindows()queries both[DAILY_ENDPOINT, PROD_ENDPOINT]concurrently and merges by first-seenwindow.id:for (const window of responses.flat()) if (!windows.has(window.id)) windows.set(window.id, window);- Consequently, whenever
daily-cloudcode-pahits0%remaining and omitsremainingFraction,quotaWindow()discards it andfetchWindows()backfills the missinggemini-5h/gemini-weeklywindow withremainingFraction: 1(100% left) fromcloudcode-pa.googleapis.com.
Bug 3: antigravityUsageReader.ts is missing gemini-4-neon (modelId: 1532)#
In src/provider/Drivers/antigravityUsageReader.ts, the numeric model ID map ends at 1417–1419 (gemini-4-argon). Native Antigravity conversation databases record gemini-4-neon as modelId: 1532 (MODEL_PLACEHOLDER_M532), so local Antigravity usage scanning does not map gemini-4-neon records.
Expected behavior / suggested fixes#
- Clear or overwrite
acp_token.jsonon Antigravity logout/re-auth (or read credentials consistently with Antigravity ACP's keyring auth). - In
antigravityUsageLimits.ts:- Treat an omitted
remainingFractionon a bucket that has aresetTime(and is notdisabled) as0(usedPercent: 100) instead of dropping the bucket. - Do not merge
cloudcode-pa.googleapis.combuckets into a non-emptydaily-cloudcode-pa.googleapis.comresponse (or only fall back to the secondary endpoint when the primary endpoint fails / returns no buckets).
- Treat an omitted
- Add
1532(gemini-4-neon) to the model ID map inantigravityUsageReader.ts.
Note: These issues were investigated and found using Gemini 4 Neon.
tanstack-source added labelsbug
juliusmarminge closed this
Confirming this still reproduces on T3 Code
0.1.11on both macOS and Linux, specifically for the staleacp_token.jsonvs.antigravity-oauth-tokenmismatch (which also reproduced in the unit test in the comment above).Environment#
- T3 Code version:
0.1.11(reproduced on bothT3 Code (Beta)desktop on macOS and headless/linked T3 Code server0.1.11on Linux) - OS / Arch:
- macOS
27.2(darwin-arm64) - Ubuntu
24.04.5 LTS(linux-x64)
- macOS
- Antigravity runtime: default managed
antigravity1.5.13(~/.t3/tools/antigravity-acp/<platform>/versions/...) - Auth method:
oauth-personal(Google account sign-in)
What happened on disk#
In
<stateDir>/userdata/providers/antigravity/<instance>/antigravity-acp/, both credential files were present simultaneously on both machines:acp_token.json— older file from an earlier sign-in with Account A (containsclient_id,client_secret,refresh_token,token_uri,scopes,project_id)antigravity-oauth-token— newer file written by the1.5.13runtime for Account B (containstoken,auth_method,id_token_email)
The active Antigravity
1.5.13sessions were running under Account B (verified both via model entitlement only present on Account B and Google's userinfo endpoint on the token inantigravity-oauth-token), while T3 Code's usage limits probe was readingacp_token.jsonand reporting Account A's quota.Exact reproduction steps#
- Start with an Antigravity provider profile that previously signed in to Account A on an older runtime so
<stateDir>/userdata/providers/antigravity/<instance>/antigravity-acp/acp_token.jsonexists on disk. - On T3 Code
0.1.11with the managedantigravity1.5.13runtime, sign in to Account B. This writesantigravity-oauth-tokenin the same directory but leaves the olderacp_token.jsonintact. - Run turns in T3 Code (sessions authenticate as Account B via
antigravity-oauth-token) and check the Antigravity usage limits UI. - Observed: Usage limits display Account A's quota instead of Account B's, because
makeAntigravityUsageProbeinapps/server/src/provider/antigravityUsageLimits.tsonly checkscliTokenPath(antigravity-oauth-token) whentokenPath(acp_token.json) does not exist (if (!(yield* fs.exists(tokenPath)))). - Workaround verified: Deleting the stale
acp_token.jsonimmediately causes the probe to fall through toantigravity-oauth-token.
Suggested fix#
In
apps/server/src/provider/antigravityUsageLimits.ts, preferantigravity-oauth-token(cliTokenPath) overacp_token.json(tokenPath) when both files exist (and/or removeacp_token.jsonon logout / re-auth).- T3 Code version:
Sign in to join this conversation.
I tried to reproduce this on the current build and could not.
Commit c813e7db51 (origin/main). The Antigravity usage-limits panel needs a Google account sign-in, which no VM has, so I could not see the wrong percentage in the app. I reproduced the two limits bugs as failing tests in apps/server/src/provider/antigravityUsageLimits.test.ts. Both fail on main with
vp test run src/provider/antigravityUsageLimits.test.ts(2 failed, 20 passed). (1) 'reports an exhausted daily quota instead of the prod host's untouched reading': for a personal account, daily-cloudcode-pa returns gemini-5h with only a resetTime (proto3 omits remainingFraction 0) and cloudcode-pa returns remainingFraction 1. Main reports usedPercent 0 ('100% left') instead of 100. (2) 'reads the native CLI's current sign-in over a leftover acp_token.json': the profile holds a valid antigravity-oauth-token from the 1.5.x CLI plus a leftover acp_token.json from an earlier account. Main posts refresh_token=previous-account to oauth2.googleapis.com/token, so it reports the old account's quota. For Bug 3 I ran it in the app: a dev server on a fresh database (T3CODE_DEV_SEED=0, GOOGLE_GEMINI_BASE_URL pointed at the hub), an Antigravity instance added in Settings > Providers with sign-in method 'Gemini API key' (authenticated on agy v1.5.13, the reporter's version), and one Gemini 4 Neon turn that answered 'OK'. Main's readAntigravityUsage on that turn's conversation database returned model 'gemini-4-neon' with no errors. The model was resolved from the name in gen_metadata ('gemini-4-neon-low'), and the database held no 1532 varint. So the missing 1532 entry did not show here, and I could not confirm that 1532 is Neon.Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.