Skip to content

fix(server): Antigravity usage limits ignore leftover acp_token.json - #42623

Closed
Waishnav wants to merge 1 commit into
pingdotgg:mainfrom
Waishnav:fix/antigravity-ignore-legacy-acp-token
Closed

Waishnav wants to merge 1 commit into
pingdotgg:mainfrom
Waishnav:fix/antigravity-ignore-legacy-acp-token

Conversation

@Waishnav

@Waishnav Waishnav commented Nov 25, 2026 •

Copy link
Copy Markdown

Problem

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.json OAuth refresh path and its refreshed-token cache (clear) from makeAntigravityUsageProbe in apps/server/src/provider/antigravityUsageLimits.ts (T3 Code already refuses pre-1.5 Antigravity runtimes that wrote that file).
  • makeAntigravityUsageProbe now reads only antigravity-oauth-token (or the OS keyring for oauth-business when no file is present), ignoring any leftover acp_token.json.
  • Removed the now-unused clearUsage wiring in apps/server/src/provider/Drivers/AntigravityDriver.ts.
  • Updated apps/server/src/provider/antigravityUsageLimits.test.ts to test CLI sign-in probes directly, verify distinct Authorization headers across sign-in changes, and cover leftover acp_token.json alongside valid, expired, and absent CLI credentials.

Scope

Fixes #40015 and #34381. Supersedes the stalled #39544 with live-profile verification.

Verification

Before (with acp_token.json shadowing antigravity-oauth-token)

image

After (this branch, with acp_token.json still present on disk)

image

Prepared with Gemini 4 Neon via Antigravity in T3 Code.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T05:09:44.454222Z c6d4293 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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.ts
The 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.ts
Quota 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.ts
The 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 data
Loading

Possibly 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-token and 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

Merge Risk: Minimal · up to c6d42

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed Objective [#40015]: show accurate 5-hour and weekly Antigravity usage, and detect Argon's separate quota for Pro/Plus accounts. At the reviewed head, summaryWindows in `apps/server/src/provider/anti…
Out of Scope Changes check Passed All changes relate to the credential-source fix for the stale-token bug in the linked issue. The diff removes the acp_token.json OAuth refresh path, the TokenFile and TokenResponse schemas, the …
Description check Passed 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, summaryWindows in apps/server/src/provider/antigravityUsageLimits.ts maps gemini-argon-* buckets to a separate family (Gemini Argon or the group display name). It also maps 5h and weekly windows to session and weekly kinds 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: makeAntigravityUsageProbe now reads antigravity-oauth-token (or the keyring for oauth-business) and ignores a stale acp_token.json. This removes the fallback to fetchAvailableModels that reported 100% left when the stale credential returned 403. 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.json OAuth refresh path, the TokenFile and TokenResponse schemas, the refreshed-token cache, and the clear return value. It also removes the matching clearUsage wiring in AntigravityDriver.ts and 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 #40015 and #34381 and 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

Commits

Reviewing files that changed from the base of the PR and between e2c3c42 and c6d4293.

Files selected for processing: 3

  • apps/server/src/provider/Drivers/AntigravityDriver.ts
  • apps/server/src/provider/antigravityUsageLimits.test.ts
  • apps/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.

@juliusmarminge

Copy link
Copy Markdown
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Antigravity Usage Limits broken for Google One Pro/Plus Users

2 participants