fix(server): Antigravity usage limits ignore leftover acp_token.json #42623
main fromrefs/pull/42623/head·opened View on GitHubProblem#
Antigravity usage limits can stay stuck at 100% left (falling back to Reported quota with a rolling 4h 59m reset) or show another Google account's limits whenever an upgraded profile still has a leftover antigravity-acp/acp_token.json alongside the 1.5.x agy CLI's antigravity-oauth-token.
makeAntigravityUsageProbe checked fs.exists(acp_token.json) first, so any profile carrying a pre-1.5 acp_token.json always refreshed and queried Google with that stale credential instead of the active CLI sign-in. When the stale account returned 403 PERMISSION_DENIED (VALIDATION_REQUIRED) on retrieveUserQuotaSummary, the probe silently fell back to fetchAvailableModels and reported 100% left across Gemini / Claude / GPT · Reported quota.
Change#
- Removed the legacy
acp_token.jsonOAuth refresh path and its refreshed-token cache (clear) frommakeAntigravityUsageProbeinapps/server/src/provider/antigravityUsageLimits.ts(T3 Code already refuses pre-1.5 Antigravity runtimes that wrote that file). makeAntigravityUsageProbenow reads onlyantigravity-oauth-token(or the OS keyring foroauth-businesswhen no file is present), ignoring any leftoveracp_token.json.- Removed the now-unused
clearUsagewiring inapps/server/src/provider/Drivers/AntigravityDriver.ts. - Updated
apps/server/src/provider/antigravityUsageLimits.test.tsto test CLI sign-in probes directly, verify distinctAuthorizationheaders across sign-in changes, and cover leftoveracp_token.jsonalongside valid, expired, and absent CLI credentials.
Scope#
Fixes #40015 and #34381. Supersedes the stalled #39544 with live-profile verification.
Verification#
- Live profile check (Linux x64,
agy 1.5.16,oauth-personal): Against a real profile containing both a leftoveracp_token.json(which returned403onretrieveUserQuotaSummaryand fell back to100%Reported quota) and a freshantigravity-oauth-token, running the patchedmakeAntigravityUsageProbereturned all 4 summary windows from the active account (Gemini · 5-hourat 15.12% used,Gemini · Weeklyat 5.35% used,Claude & GPT (shared) · 5-hourandWeeklyat 0% used) with real reset timestamps whileacp_token.jsonremained untouched on disk. - Checks:
vp run check:changedpassed (format,lint,knip2/2,graphql,typecheckacross 3 packages, andvp testacross 3 files: 31 passed, 1 Windows-only keyring test skipped on Linux). - Not verified here: Windows Credential Manager path (skipped on Linux) and macOS Keychain behavior with
agy 1.5.16(tracked separately in #41973 / #41982).
Before (with acp_token.json shadowing antigravity-oauth-token)#
After (this branch, with acp_token.json still present on disk)#
Prepared with Gemini 4 Neon via Antigravity in T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
No actionable comments were generated in the recent review.
Walkthrough
-
The Antigravity usage probe now reads the CLI token file and uses a keyring fallback for business sign-ins. It sends quota requests with the saved access token, rejects missing or near-expiry credentials, and no longer caches credentials or exposes a clear operation.
Changes: Antigravity usage probe
Layer / File(s) Summary CLI credential resolution
apps/server/src/provider/antigravityUsageLimits.ts,apps/server/src/provider/antigravityUsageLimits.test.tsThe probe reads credentials from the CLI token file and falls back to the keyring for business sign-ins. It checks token expiry and derives the account fingerprint from user information, with a token hash fallback. Tests cover missing, malformed, and expiring credentials. Authenticated quota requests
apps/server/src/provider/antigravityUsageLimits.ts,apps/server/src/provider/antigravityUsageLimits.test.tsQuota requests use the saved access token and an empty request body. Tests verify authorization headers and the request body. Credential rereads and probe contract
apps/server/src/provider/antigravityUsageLimits.ts,apps/server/src/provider/Drivers/AntigravityDriver.ts,apps/server/src/provider/antigravityUsageLimits.test.tsThe probe no longer caches credentials or returns a clear operation. The driver no longer supplies clearUsage. Tests verify that changed credentials are used and that a missing CLI token file returns an unsupported result.Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)#
sequenceDiagram participant Probe as makeAntigravityUsageProbe participant CliFile as antigravity-oauth-token participant Keyring participant UserInfo as User-info endpoint participant Quota as Quota endpoint Probe->>CliFile: Read CLI credentials CliFile-->>Probe: Return saved access token opt oauth-business and CLI credentials unavailable Probe->>Keyring: Read business access token Keyring-->>Probe: Return access token end Probe->>UserInfo: Look up account with saved access token UserInfo-->>Probe: Return account data Probe->>Quota: Send quota request with access token and empty body Quota-->>Probe: Return quota dataPossibly related issues
- Issue 34381: The probe no longer reads or refreshes credentials from
acp_token.json, which matches the issue’s reported stale-account cause. The issue’s account display suggestion is not covered. - Issue 41973: The probe reads
antigravity-oauth-tokenand uses the keyring for business sign-ins. The issue’s personal-account keyring gap and SSH or environment-variable storage cases are not covered.
Suggested reviewers:
juliusmarminge - Issue 34381: The probe no longer reads or refreshes credentials from
Merge Risk:
Minimal · up toc6d42-
The Antigravity usage probe now uses the active CLI sign-in credentials and ignores the stale legacy token file, which addresses the incorrect quota display. No concrete merge-blocking risk was found. Windows and macOS sign-in behavior has not been verified and is tracked in follow-up issues.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: the Antigravity usage probe no longer reads a leftover acp_token.json, which caused stale-account quota results. It uses the conventional commit form. The title is spe… Linked Issues check Objective [ #40015]: show accurate 5-hour and weekly Antigravity usage, and detect Argon's separate quota for Pro/Plus accounts. At the reviewed head,summaryWindowsin `apps/server/src/provider/anti…Out of Scope Changes check All changes relate to the credential-source fix for the stale-token bug in the linked issue. The diff removes the acp_token.jsonOAuth refresh path, theTokenFileandTokenResponseschemas, the …Description check The description is thorough and follows the repository template. It has a Problem section that explains the stale acp_token.json shadowing the active CLI credential, a Change section listing the remov… Full details: Title check
-
Explanation
The title names the main change: the Antigravity usage probe no longer reads a leftover acp_token.json, which caused stale-account quota results. It uses the conventional commit form. The title is specific and matches the summary, the description, and the objectives.
Full details: Linked Issues check
-
Explanation
Objective [
#40015]: show accurate 5-hour and weekly Antigravity usage, and detect Argon's separate quota for Pro/Plus accounts. At the reviewed head,summaryWindowsinapps/server/src/provider/antigravityUsageLimits.tsmapsgemini-argon-*buckets to a separate family (Gemini Argonor the group display name). It also maps5handweeklywindows tosessionandweeklykinds with window lengths. The diff against the merge base does not change this code, so the Argon handling already exists and this PR does not need to add it. The PR changes the credential source:makeAntigravityUsageProbenow readsantigravity-oauth-token(or the keyring foroauth-business) and ignores a staleacp_token.json. This removes the fallback tofetchAvailableModelsthat reported100% leftwhen the stale credential returned403. The PR reports a live Linux check that returned four summary windows from the active account. That check does not show an Argon bucket, and the summary does not show a test that covers an Argon-only account. Argon detection therefore rests on existing code, not on new verification.
Full details: Out of Scope Changes check
-
Explanation
All changes relate to the credential-source fix for the stale-token bug in the linked issue. The diff removes the
acp_token.jsonOAuth refresh path, theTokenFileandTokenResponseschemas, the refreshed-token cache, and theclearreturn value. It also removes the matchingclearUsagewiring inAntigravityDriver.tsand changes the quota request body to{}, because the project ID came from the removed file. The test file changes cover the CLI token path that the fix depends on. No change falls outside the stated objective.
Full details: Description check
-
Explanation
The description is thorough and follows the repository template. It has a Problem section that explains the stale acp_token.json shadowing the active CLI credential, a Change section listing the removed refresh path and the updated tests, a Scope section linking
#40015and#34381and citing the superseded#39544, and a Verification section with a live Linux profile check, the checks that were run, and the items not verified. Before and after screenshots are included for the UI-visible result. The template asks for the model and harness used, and the description says it was prepared with Gemini 4 Neon via Antigravity in T3 Code, so that line is present. The main gap is that the Scope section does not say why the change is a bug fix rather than a feature, though it is clearly a bug fix. The check passes.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: e2c3c42
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
fd247e5e-ac2c-4adc-9bf9-b246b161bfcd
Commits-
Reviewing files that changed from the base of the PR and between e2c3c4250d419df67fac9bbfa7f01b62d0b76bca and c6d42936ecedf2d7d246a8edafce79fabf02c210.
Files selected for processing: 3-
apps/server/src/provider/Drivers/AntigravityDriver.tsapps/server/src/provider/antigravityUsageLimits.test.tsapps/server/src/provider/antigravityUsageLimits.ts
Files with no reviewable changes: 1-
- apps/server/src/provider/Drivers/AntigravityDriver.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
-
Waishnav(GitHub profile, opens in a new tab) linked this to fix #40015
tanstack-source added labelsbug
Closing this: #43026 removed the Antigravity usage-limit reads entirely. The Antigravity team confirmed that only ACP is supported for external clients and that calling internal APIs (
cloudcode-pa.googleapis.com/v1internal) can flag a user's account. The code this PR changes no longer exists. Limits will come back only if Antigravity exposes them over ACP. Thanks for the work on this!juliusmarminge closed this
Sign in to join this conversation.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
c6d4293ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.