Skip to content

fix(rate-limits): cool down usage reads that open agy's browser sign-in - #33297

Merged
nwparker merged 4 commits into
mainfrom
nwparker/agint-antigravity-usage-signin-popup
Oct 25, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/agint-antigravity-usage-signin-popup

Conversation

@nwparker

@nwparker nwparker commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​82 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​81
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​50 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​40

Summary (ELI5)

If you have the Antigravity CLI (agy) installed but aren't signed in, Orca's usage meter kept opening a "Continue to Google Antigravity" sign-in page in your browser. It happened again on every usage refresh. Now, when a quota read reaches agy's browser sign-in, Orca waits an hour before checking again on its own. It shows "Sign in with agy; Orca checks again within an hour, or when you refresh" until then, and recovers on the next poll after the hour.

Root cause

  • Orca reads quota with agy -p /usage --output-format json --print-timeout 20s (src/main/rate-limits/antigravity-usage-command.ts).
  • When agy 1.4.2 is signed out in print mode, its log shows printmode.go:403 not authenticated, trying silent auth → printmode.go:409 silent auth failed → printmode.go:426 triggering interactive OAuth → browser.go:56 consumerOAuth: starting OAuth flow. It then calls the OS opener (open <accounts.google.com/o/oauth2/auth?...> on macOS; the agy changelog says rundll32 on Windows), prints Authentication required. Please visit the URL to log in: and Waiting for authentication (timeout 60s)..., and blocks.
  • This only happens when agy can reach a terminal. Its changelog says print mode pastes the OAuth code "via the controlling terminal (/dev/tty on POSIX and CONIN$ on Windows)", and only "truly headless runs fail fast". Orca's hidden-console spawn on Windows, and an Orca launched from a terminal on Linux or macOS, are not truly headless. A truly headless agy fails fast with authentication required. Run 'agy' to log in and opens nothing. That case is unchanged by this PR.
  • Orca kills the read at 30 s, before agy's own 60 s wait ends. The fetcher checked timedOut first, so it reported status: 'error' / "did not answer in time". Errors are retried on window activation and on every poll, and each retry opened the browser again.

What changed

  • Fetcher: a read whose stderr contains agy's interactive-OAuth prompt (Authentication required. Please visit the URL or accounts.google.com/o/oauth2) now returns unavailable / missing-credentials with retryAtMs = now + 1h. Fast-exit sign-outs carry no retryAtMs, so they keep polling exactly as on main.
  • Policy: I renamed Claude's shouldSkipAutomatedClaudeFetch to shouldSkipAutomatedFetch(provider, limits). It is (claude || antigravity) && isRetryAfterActive(limits), so Claude's behavior does not change. The gate is used in the activation refresh plan, the Claude-only cycle and the full cycle. During the cooldown a skipped Antigravity read keeps its previous snapshot and is never marked "fetching". Forced (user-directed) refreshes bypass it, the same way they bypass Claude's Retry-After. When the hour is up, the next automated poll rechecks.

Verification

Real agy 1.4.2 against an isolated signed-out HOME, under sandbox-exec. /usr/bin/security was denied so the real keychain could not be read, and /usr/bin/open plus LaunchServices were denied. A PATH stub logged each open <url> call instead of launching a browser. I wired the real fetchAntigravityRateLimits into RateLimitService and drove automated (non-forced) cycles.

With a controlling TTY (the case that opens the browser):

step main this branch
3 automated cycles, signed out 3 agy reads / 3 browser opens, error "did not answer in time" 1 read / 1 open, unavailable, cooldown set
signed in (real HOME), inside cooldown — skipped (1 read / 1 open)
signed in, clock +61 min, automated cycle — ok, recovered (2 reads / 1 open)

Without a TTY (agy fails fast and opens nothing), this branch polls on every cycle with no cooldown, the same as main: 3 cycles, 3 reads, 0 opens.

These were temporary harnesses and are not checked in. The regression tests that are checked in:

  • antigravity-usage-fetcher.test.ts: the OAuth-prompt timeout gets a 1h retryAtMs; a fast-exit sign-out gets none.
  • service-antigravity-usage.test.ts: focus events and polls inside the cooldown do not call agy; the first poll after it does, and recovers to ok.

I also ran pnpm tc:node, targeted rate-limit tests, and pnpm run check:code-quality:changed.

Risk

  • After you sign in, the meter can take up to about 1h plus one poll interval to recover on its own. A manual refresh works immediately.
  • A user-directed refresh while still signed out can open one sign-in page.
  • The stderr match is pinned to agy's current prompt text. If agy rewords it, we fall back to main's behavior, not to a permanent latch.

Fixes #26484

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4513a9b4-1e49-472f-bacc-2f34193f0a2d
Commits

Reviewing files that changed from the base of the PR and between e18752a and b994631.

Files selected for processing: 9
  • src/main/rate-limits/antigravity-usage-command.ts
  • src/main/rate-limits/antigravity-usage-error.ts
  • src/main/rate-limits/antigravity-usage-fetcher.test.ts
  • src/main/rate-limits/antigravity-usage-fetcher.ts
  • src/main/rate-limits/service-antigravity-usage.test.ts
  • src/main/rate-limits/service/service-fetch-policy.ts
  • src/main/rate-limits/service/service-full-cycle-preparation.ts
  • src/main/rate-limits/service/service-polling.ts
  • src/main/rate-limits/service/service-provider-cycles.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…sage poll

A signed-out agy -p /usage starts interactive OAuth and opens a browser
sign-in page. Orca killed it at 30s, called it a slow CLI (status error),
and retried on every poll and window focus, so the page kept reopening.

Classify a timed-out read whose stderr is agy's sign-in prompt as signed
out, and generalize Claude's skip-automated-fetch gate so automated cycles
skip Antigravity while it is signed out. A user-directed refresh still
rechecks.

Fixes #26484
@nwparker
nwparker force-pushed the nwparker/agint-antigravity-usage-signin-popup branch from 04114ae to 882f36a Compare October 24, 2026 23:29
@nwparker nwparker changed the title fix(rate-limits): stop re-running a signed-out agy sign-in on every usage poll fix(rate-limits): cool down usage reads that open agy's browser sign-in Oct 24, 2026
@nwparker
nwparker merged commit 6017bc9 into main Oct 25, 2026
36 checks passed
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.

Antigravity usage refresh repeatedly opens a Google sign-in page when agy's silent login fails (Windows)

1 participant