fix(server): Antigravity no longer opens Google sign-in in the browser from background sessions #39509
main fromrefs/pull/39509/head·opened View on GitHubProblem#
T3 starts Antigravity runtimes in the background: turn starts (including delegated tasks), model refresh, and text generation. If the native CLI has no Google sign-in for the instance, each of those runtimes opens a Google sign-in tab in the user's default browser and then hangs. Two common ways to get there: an instance signed in on the 1.4.5 runtime, whose acp_token.json 1.5.x never reads (#36033), or an instance that was never signed in.
makeAntigravityAcpRuntime sends authenticate {methodId: "oauth-personal"} before session/new on every runtime. The 1.5.x CLI ignores T3's BROWSER helper (#36034), opens the system browser itself, and waits until it logs Sign-in timed out after 300 s. Nothing in T3 is showing that sign-in. The turn never starts, and the effect worker retries it 5 times, so the user gets a new Chrome tab every 5 minutes for 25 minutes. Model refresh fails the same way after 90 s with the generic "Could not refresh Antigravity models."
Expected: a background runtime never opens a browser. It reports right away that Google sign-in is needed. That has been the design from the start. With no onAuthorizationUrl, T3's browser helper turns the sign-in URL into "Sign in to Antigravity in Settings before you continue." (antigravityAuthSupport.ts), and the tests "ends normal work with a safe sign-in error instead of waiting for OAuth" and "rejects interactive sign-in during normal work" lock that in.
1.5.x bypasses the helper. #36037 fixed only the no-display case, and its description names this case as not addressed: "the case where a display exists and 1.5.x opens a browser on the server and waits". #38953 then closed #36034 by fixing the Settings sign-in only. On macOS there is always a display, so this is the path every Mac user hits.
Change#
For oauth-personal runtimes that no sign-in flow is watching (no onAuthorizationUrl), makeAntigravityAcpRuntime no longer sends authenticate, either before session/new or after it fails. The native CLI does not need authenticate for Google: session/new uses the stored sign-in when there is one. Without one, it returns -32000 Authentication required in about 0.1 s. isAntigravitySignInRequiredError already maps that to the instance's "Sign in with Google to use Antigravity." state, and the turn fails with "The provider needs you to sign in."
The test mock gains T3_ACP_AUTHENTICATE_SIGN_IN_TIMES_OUT, which answers a Google authenticate the way 1.5.x does when nobody finishes the browser sign-in. The driver test's signed-out executable now behaves like the native CLI, replacing the 1.4.5 browser-helper URL marker, which #38970 retired.
Scope#
Fixes #39508
- Covered: every path that builds a runtime without
onAuthorizationUrl. That is turn starts and resumes, delegated tasks, model refresh (Settings, post-install), text generation, and the fresh runtime that Sign in starts after--loginsucceeds. All clients (web, desktop, mobile) reach these through the server, so the fix covers all of them. - Unchanged: the interactive loopback sign-in, which passes
onAuthorizationUrland still authenticates eagerly. Also unchanged:oauth-business,gemini-api-keyandagent-platform. For those methodsauthenticatepicks the credential source, and I could not checkoauth-businessagainst a real Gemini Enterprise account. - Not in scope:
- Carrying an old
acp_token.jsonsign-in over to 1.5.x (#36033). - Whether the effect worker should retry a turn that failed with sign-in required. With this change those retries each finish in about a second and never open a browser.
- Resuming a signed-out thread now launches the CLI twice.
session/resumereturns-32000, and the shared ACP adapter retries any failed resume or load with a freshsession/new(packages/provider-acp/src/server/adapter.ts). Both launches take about 0.1 s and the result is still sign-in required. That fallback is shared by every ACP provider, so I left it alone. - When
readThreadSnapshotrestarts a runtime throughloadSession, the sign-in-required error does not pass through the driver'sonAuthRequired, so the instance status is not updated on that path. This was already true onmain, where the same path opened a browser and hung for 300 s; now it fails fast.
- Carrying an old
Verification#
Desktop with a display, managed Antigravity 1.5.13, Google-personal sign-in#
I set this up on an Ubuntu 24.04 arm64 VM with a real Xfce desktop (X11, DISPLAY=:0) and Firefox as the xdg-open browser. The isolated dev server ran from this repo at main @ 7f928416b2 (the main parent of this PR's head) and at the PR head c42c152f94. T3 installed the managed runtime itself from Settings → Install Antigravity: antigravity 1.5.13, linux-arm64. The server ran with the desktop session's environment and no SSH_* variables, so the CLI treats it as a local desktop. In SSH mode it answers "No browser is available here" instead. The test project and the Antigravity instance were fresh. The account is a real Google personal account.
Background turn (t3 thread start <project> "say hi" --provider antigravity --model antigravity-default):
main @ 7f928416b2 | PR head @ c42c152f94 | |
|---|---|---|
| Signed out | initialize → authenticate oauth-personal → Opening browser for ACP sign-in. Firefox opens "Sign in to continue to Google Antigravity" on the desktop. After 300 s: Sign-in timed out. The worker then retries and a new runtime opens the sign-in page again. The thread is still starting after 531 s. | initialize → session/new → -32000. The thread is failed after 1 s with "The provider needs you to sign in". No authenticate, no browser window. |
| Signed in | authenticate OK in 0.7 s, then session/new, session/prompt. Reply: "Hi! How can I help you today?" | session/new (stored sign-in: ChainedAuth: authenticated via keyring), session/prompt. Same reply in about 5 s. No authenticate. |
Model refresh (Settings → Providers → Refresh provider status):
main @ 7f928416b2 | PR head @ c42c152f94 | |
|---|---|---|
| Signed out | authenticate → Opening browser for ACP sign-in. It blocks until T3's 90 s refresh timeout cancels it (Sign-in was cancelled). The card still says "Installed · Sign-in not checked". | initialize → session/new. About 4 s later the card says "Not authenticated · Sign in with Google to use Antigravity." No browser. |
| Signed in | not run | session/new and the model options load. The card stays "Authenticated · Google account". |
Interactive Settings sign-in on the PR head (Settings → Providers → Antigravity → Account → Sign in). T3 ran the CLI's --login, showed the Google link and the "Code from the Antigravity page" field, and opened the link in Firefox. After the Google sign-in, the code went into that field and Connect finished it. The CLI log shows consumerOAuth: authentication completed successfully. The fresh runtime T3 starts next ran initialize → session/new (ChainedAuth: authenticated via keyring) → session/set_config_option and published the catalog. The card shows "Authenticated · Google account" and Account shows "Signed in." The turns and refresh in the "Signed in" rows above ran on that sign-in.
Captures
main: a background turn opens Google sign-in on the desktop
main after the 90 s refresh, then the PR head after a 4 s refresh
PR head after the interactive Settings sign-in
Tests and the macOS run#
Test. AntigravityDriver.test.ts > "closes refresh processes and clears account metadata when Google sign-in is required" now uses a signed-out 1.5-style executable. It asserts the sign-in-required error and state, and a request log of initialize, session/new per refresh with no authenticate. It fails on main: expected 'Could not refresh Antigravity models.…' to contain 'Sign in to Antigravity'. It passes with the change. "refreshes the selected executable…" now expects no auth/login for a signed-in profile; it also fails with only AntigravityAcpSupport.ts reverted. vp run check:changed passes, and so do the six Antigravity/ACP test files (173 tests).
Real CLI, 1.5.13 on macOS arm64, launched the way T3 launches it (acp --gemini-dir <profile> --app-data-dir antigravity-acp):
| Profile | authenticate first | No authenticate |
|---|---|---|
| Signed out | Opens the system browser and waits (Opening browser for ACP sign-in) | session/new → -32000 Authentication required in 0.1 s |
| Signed in (file token) | OK in 0.9 s, then session/new OK | session/new OK in 1.2 s with the full model list, also with no settings.json |
App, isolated dev server, same managed 1.5.13 runtime, a fresh Antigravity instance, t3 thread start <project> "say hi" --provider antigravity --model antigravity-default. An open shim on the login shell's PATH logged every browser launch the CLI attempted, so no real tabs opened.
main @ 9bb92a46dd: browser opened, thread still starting after 100 s
ACP Request received: initialize
ACP Request received: authenticate
ACP authenticate: methodId="oauth-personal" meta=map[]
Opening browser for ACP sign-in (method=consumer, redirect=http://localhost:51648/auth/callback)
browser launches caught by the open shim: 1
The same happens on nightly v0.1.11-nightly.20261119.4954.
This branch: no browser, thread failed after 1 s with a sign-in prompt
ACP Request received: initialize
ACP Request received: session/new
browser launches caught by the open shim: 0
Not checked: a real Gemini Enterprise (oauth-business) account, and Windows. oauth-business keeps its eager authenticate, so this change doesn't affect it. macOS (above) and a Linux desktop (top of this section) are covered end to end.
Claude Opus 5.5 in Claude Code, via T3 Code.
- 1
- 2
Pushedc42c152
juliusmarminge added labelstakeover:blocked
juliusmarminge removed labelstakeover:in-progress
@juliusmarminge, on the factory stop ("cannot prove"): the three checks it couldn't run are now done on a desktop with a display, managed Antigravity 1.5.13 and a real Google-personal account, on both
main@ 7f928416b2 (this head's main parent) and the head @ c42c152f94. The machine is an Ubuntu 24.04 arm64 VM with an Xfce X11 desktop and Firefox as thexdg-openbrowser. T3 installed the runtime itself from Settings. The full tables, logs and captures are in the PR body under "Desktop with a display".- Background turn, signed out. On
main:authenticate→Opening browser for ACP sign-in. Firefox opens "Sign in to continue to Google Antigravity", the CLI times out after 300 s, the worker retries, and the page opens again. The thread is stillstartingafter 531 s. On the head:initialize→session/new→-32000, the thread fails after 1 s with "The provider needs you to sign in", and no browser opens. - Model refresh, signed out. On
main:authenticateopens the browser flow and blocks until the 90 s refresh timeout, and the card stays "Sign-in not checked". On the head: about 4 s, then "Not authenticated · Sign in with Google to use Antigravity", and no browser. - Interactive Settings sign-in on the head works. Sign in ran
--loginand showed the Google link and code field. After Google, Connect gave "Authenticated · Google account", and the follow-up runtime opened its session withsession/newalone (ChainedAuth: authenticated via keyring). - Signed-in paths are unchanged. A turn replies on both commits ("Hi! How can I help you today?"). The head never sends
authenticate, and its refresh loads the model options and stays authenticated.
The macOS 1.5.13 runtime results from the original verification still stand. The head is mergeable with green checks.
- Background turn, signed out. On
Thanks for this. Main has the change since #39485.
Main now prevents signed-out Google-account background sessions from opening browser tabs or waiting for OAuth, while preserving explicit Settings sign-in. Compared your ACP authentication-order change with the merged SSH environment setting and existing turn/model-refresh error handlers; agy 1.5.13 with a fresh profile immediately returned the recognized sign-in-required error.
Closing as superseded.
juliusmarminge closed this
Sign in to join this conversation.
The automated pipeline stopped on this pull request and will not merge it:
the fix is written and reviewed, but proving it needs something no worker has:
It stays open for a person to finish or close.