Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Antigravity usage limits stay at 100% left after account switch and at 0% exhaustion (stale acp_token.json + cloudcode-pa backfill) #39828

Closedinj-src(GitHub profile, opens in a new tab) opened this issue 2 comments

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:

  1. Earlier login with Google Account A created <stateDir>/providers/antigravity/<instance>/antigravity-acp/acp_token.json.
  2. 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 older acp_token.json untouched on disk.
  3. makeAntigravityUsageProbe in src/provider/antigravityUsageLimits.ts reads acp_token.json directly and never reads the keyring or clears/invalidates stale acp_token.json on logout/re-auth.
  4. 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, same project: "aicode-consumers"):
    • gemini-5h: remainingFraction: 1 (100% left)
    • gemini-weekly: remainingFraction: 1 (100% left)

In src/provider/antigravityUsageLimits.ts:

  • quotaWindow() drops any bucket where quota.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-seen window.id:
    for (const window of responses.flat()) if (!windows.has(window.id)) windows.set(window.id, window);
  • Consequently, whenever daily-cloudcode-pa hits 0% remaining and omits remainingFraction, quotaWindow() discards it and fetchWindows() backfills the missing gemini-5h / gemini-weekly window with remainingFraction: 1 (100% left) from cloudcode-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

  1. Clear or overwrite acp_token.json on Antigravity logout/re-auth (or read credentials consistently with Antigravity ACP's keyring auth).
  2. In antigravityUsageLimits.ts:
    • Treat an omitted remainingFraction on a bucket that has a resetTime (and is not disabled) as 0 (usedPercent: 100) instead of dropping the bucket.
    • Do not merge cloudcode-pa.googleapis.com buckets into a non-empty daily-cloudcode-pa.googleapis.com response (or only fall back to the secondary endpoint when the primary endpoint fails / returns no buckets).
  3. Add 1532 (gemini-4-neon) to the model ID map in antigravityUsageReader.ts.

Note: These issues were investigated and found using Gemini 4 Neon.

  1. tanstack-source added labelsbug

  2. 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.

  3. juliusmarminge closed this

  4. Confirming this still reproduces on T3 Code 0.1.11 on both macOS and Linux, specifically for the stale acp_token.json vs. antigravity-oauth-token mismatch (which also reproduced in the unit test in the comment above).

    Environment

    • T3 Code version: 0.1.11 (reproduced on both T3 Code (Beta) desktop on macOS and headless/linked T3 Code server 0.1.11 on Linux)
    • OS / Arch:
      • macOS 27.2 (darwin-arm64)
      • Ubuntu 24.04.5 LTS (linux-x64)
    • Antigravity runtime: default managed antigravity 1.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 (contains client_id, client_secret, refresh_token, token_uri, scopes, project_id)
    • antigravity-oauth-token — newer file written by the 1.5.13 runtime for Account B (contains token, auth_method, id_token_email)

    The active Antigravity 1.5.13 sessions were running under Account B (verified both via model entitlement only present on Account B and Google's userinfo endpoint on the token in antigravity-oauth-token), while T3 Code's usage limits probe was reading acp_token.json and reporting Account A's quota.

    Exact reproduction steps

    1. 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.json exists on disk.
    2. On T3 Code 0.1.11 with the managed antigravity 1.5.13 runtime, sign in to Account B. This writes antigravity-oauth-token in the same directory but leaves the older acp_token.json intact.
    3. Run turns in T3 Code (sessions authenticate as Account B via antigravity-oauth-token) and check the Antigravity usage limits UI.
    4. Observed: Usage limits display Account A's quota instead of Account B's, because makeAntigravityUsageProbe in apps/server/src/provider/antigravityUsageLimits.ts only checks cliTokenPath (antigravity-oauth-token) when tokenPath (acp_token.json) does not exist (if (!(yield* fs.exists(tokenPath)))).
    5. Workaround verified: Deleting the stale acp_token.json immediately causes the probe to fall through to antigravity-oauth-token.

    Suggested fix

    In apps/server/src/provider/antigravityUsageLimits.ts, prefer antigravity-oauth-token (cliTokenPath) over acp_token.json (tokenPath) when both files exist (and/or remove acp_token.json on logout / re-auth).

Sign in to join this conversation.