fix(server): Antigravity 1.5.16 Google sign-ins stay in profile storage #41982
main fromrefs/pull/41982/head·opened View on GitHubProblem#
Starting with Antigravity CLI 1.5.16, composite_token_storage.go no longer falls back to file-based token storage solely because SSH_CONNECTION is set when a system keyring (such as macOS Keychain) is available, and it ignores AGY_ACP_FORCE_FILE_STORAGE. Instead, 1.5.16 checks AGY_CLI_FORCE_FILE_TOKEN_STORAGE.
Because antigravityEnvironment did not set AGY_CLI_FORCE_FILE_TOKEN_STORAGE, personal Google (oauth-personal) sign-ins (agy acp --login) and sessions on 1.5.16 silently read and wrote the shared OS keyring instead of <profile>/antigravity-acp/antigravity-oauth-token. That broke per-instance account isolation and caused makeAntigravityUsageProbe (which skips the shared keyring for oauth-personal) to report "Sign in with Google to see Antigravity limits.".
Change#
- In
apps/server/src/provider/antigravityAuthSupport.ts:- Add
AGY_CLI_FORCE_FILE_TOKEN_STORAGEtoremovedEnvironmentKeysso ambient values (including case-insensitive Windows aliases) cannot override"1"foroauth-personalor leak into other auth methods. - Set
AGY_CLI_FORCE_FILE_TOKEN_STORAGE: "1"inantigravityEnvironmentforoauth-personal, keepingSSH_CONNECTION(needed by1.5.12–1.5.15for file storage and by1.5.16for headlessNo browser is available heredetection) andAGY_ACP_FORCE_FILE_STORAGE: "1". - Leave
oauth-business(Gemini Enterprise) unchanged so existing Enterprise keyring sign-ins andantigravityUsageLimits.ts's keyring fallback keep working.
- Add
- In
apps/server/src/provider/antigravityAuthSupport.test.ts:- Assert that ambient
AGY_CLI_FORCE_FILE_TOKEN_STORAGE(and its lowercase alias) is stripped and set to"1"foroauth-personal, and stripped (undefined) forgemini-api-key,agent-platform, andoauth-business.
- Assert that ambient
Note: oauth-personal users who already signed in on 1.5.16 before this fix have their token only in the shared OS keyring and will need to sign in once after upgrading so antigravity-oauth-token is written into the profile (any previous shared keyring entry is left untouched).
Scope#
Fixes #41973
Verification#
- Before (
main@4afdfefde0, macOS arm64 with live macOS Keychain, managed Antigravity CLI1.5.16):- Spawning
antigravity acpwithSSH_CONNECTION="127.0.0.1 0 127.0.0.1 0"andAGY_ACP_FORCE_FILE_STORAGE=1(noAGY_CLI_FORCE_FILE_TOKEN_STORAGE) against a profile containing a syntheticantigravity-oauth-tokenignored the profile file and loaded the macOS Keychain account instead;antigravity acp --logindid not log file-based token storage. vp test run apps/server/src/provider/antigravityAuthSupport.test.tsfailed the 2 updated assertions (AGY_CLI_FORCE_FILE_TOKEN_STORAGE=0and lowercase alias leaked through; ambientAGY_CLI_FORCE_FILE_TOKEN_STORAGE=1leaked into non-personal methods).
- Spawning
- After fix:
- Live checks against managed Antigravity CLI
1.5.16viaprepareAntigravityProfile+buildAntigravityAcpSpawnInputwith realHOME(macOS Keychain active):oauth-personalwith a synthetic profileantigravity-oauth-tokenand ambientAGY_CLI_FORCE_FILE_TOKEN_STORAGE=0: loggedcomposite_token_storage.go:207] Using file-based token storage because AGY_CLI_FORCE_FILE_TOKEN_STORAGE is setand authenticated as the profile token (e2e-profile@example.com), not the macOS Keychain account.oauth-personalwith an empty profile: logged file-based token storage and returned JSON-RPC error-32603(No browser is available here...), without reading macOS Keychain.oauth-personalacp --login(matchingAntigravityDriver.codeLoginenv): logged file-based token storage and printed the Google OAuth URL.oauth-businesswith ambientAGY_CLI_FORCE_FILE_TOKEN_STORAGE=1: stripped (undefined).
vp test run apps/server/src/provider/antigravityAuthSupport.test.ts apps/server/src/provider/Drivers/AntigravityDriver.test.ts apps/server/src/provider/antigravityUsageLimits.test.ts→ 59 passed, 1 skipped (Windows-only).vp run check:changed→ format, lint, knip, graphql, typecheck (3 packages), and tests (2 files) all pass.- Did not test Linux or Windows runtime hosts directly; Windows case-insensitive stripping is covered by unit tests.
- Live checks against managed Antigravity CLI
Built with Gemini 4 Neon in T3 Code (Antigravity harness); independently reviewed by Claude Fable 5.2 and GPT-6.2-Sol.
- 1
- 2
Pushed02f8fd0
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XS
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
juliusmarminge added labelstakeover:blocked
juliusmarminge removed labelstakeover:in-progress
Tested this branch locally on macOS (arm64) with managed Antigravity
1.5.16(oauth-personal) against an isolated--home-dir:- Before (
0.1.11/ withoutAGY_CLI_FORCE_FILE_TOKEN_STORAGE):1.5.16fell back to macOS Keychain (ChainedAuth: authenticated via keyring), never wroteantigravity-oauth-token, and Usage → Limits returned"Sign in with Google to see Antigravity limits." - After (
#41982): bothacp-loginandacp-serverlogUsing file-based token storage because AGY_CLI_FORCE_FILE_TOKEN_STORAGE is set,<profile>/antigravity-acp/antigravity-oauth-token(0600) is written on sign-in, and Usage → Limits immediately populates all 4 quota windows (Gemini · 5-hour,Gemini · Weekly,Claude & GPT (shared) · 5-hour,Claude & GPT (shared) · Weekly). - Unit tests (
antigravityAuthSupport.test.ts,antigravityUsageLimits.test.ts): 51 passed, 1 skipped.
- Before (
Tested the env change from this PR on macOS arm64 with T3 Code Nightly
0.1.12-nightly.20261124.5209,oauth-personal, and an external Homebrewagy1.5.16 (antigravity-clicask, found onPATH, no managed runtime, nobinaryPath).I didn't build the branch. The PR's only runtime change for
oauth-personalisAGY_CLI_FORCE_FILE_TOKEN_STORAGE=1, and the current Nightly passes that variable through, so I set it withlaunchctl setenv AGY_CLI_FORCE_FILE_TOKEN_STORAGE 1, restarted T3, then signed out and back in.A/B with the same binary, a fresh empty profile per run (
agy acp --gemini-dir <tmp> --app-data-dir antigravity-acp), T3's current env (SSH_CONNECTION=127.0.0.1 0 127.0.0.1 0,AGY_ACP_FORCE_FILE_STORAGE=1), then ACPinitializeandauthenticate("oauth-personal"):without the variable with AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1storage log no file-storage line Using file-based token storage because AGY_CLI_FORCE_FILE_TOKEN_STORAGE is setauth ChainedAuth: authenticated via keyring, signed in as my Google accountNo browser is available here (this is a remote (SSH) session…)Without the variable, an empty profile signs in with whatever account is in the shared Keychain entry (
gemini/antigravity).My real T3 profile, before:
- No
acp_token.jsonorantigravity-oauth-tokenin<profile>/antigravity-acp/. - ACP log:
ChainedAuth: authenticated via keyring, no file-storage line. - Usage → Limits: "Sign in with Google to see Antigravity limits."
After:
antigravity-oauth-tokenwritten with mode0600.- ACP log:
Using file-based token storage because AGY_CLI_FORCE_FILE_TOKEN_STORAGE is set. - The Keychain item's
mdatstayed at the time of the earlier session, before the new sign-in. - Usage → Limits shows all 4 windows:
Gemini · 5-hour,Gemini · Weekly,Claude & GPT (shared) · 5-hour,Claude & GPT (shared) · Weekly.
With file storage, 1.5.16 still logs
ChainedAuth: authenticated via keyring. ThekeyringAuthtoken expiry in that log matches the expiry in the profile's token file.I didn't test Gemini Enterprise (
oauth-business).- No
0xCUB3(GitHub profile, opens in a new tab) approved these changes
BelKed(GitHub profile, opens in a new tab) approved these changes
thank you for this! :) i can confirm manually setting
AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1makes the limits show up as they shouldBefore After Tested this fix on
agy1.5.17 across macOS arm64 and Linux arm64 (16 KiB pages).- Google OAuth stays in profile file storage (
antigravity-oauth-token) on both hosts instead of writing to the OS keyring, and sessions survive across restarts. - On macOS,
AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1only affects Google CLI auth. Hosted plugin OAuth tokens stored under Keychain serviceantigravity.plugins(tested with the Notion plugin) still read and authenticate normally.
- Google OAuth stays in profile file storage (
Adding an independent multi-profile verification on macOS arm64 with T3 Code's managed Antigravity CLI
1.5.16(~/.t3/tools/antigravity-acp/darwin-arm64/.../antigravity), since this fix still matters for per-instance account isolation even after #43026 removed usage-limits polling:- A/B isolation check against two fresh, empty
--gemini-dirprofiles (profileAandprofileB) using T3's env (SSH_CONNECTION="127.0.0.1 0 127.0.0.1 0",AGY_ACP_FORCE_FILE_STORAGE=1), sending ACPinitializethenauthenticate("oauth-personal"):- Without
AGY_CLI_FORCE_FILE_TOKEN_STORAGE: both empty profiles silently authenticated via the shared macOS Keychain ({"result":{"_meta":{"antigravity":{"tier":{"name":"Google AI Pro","id":"g1-pro-tier",...}}}}}), causing multiple configured Antigravity instances to collapse onto the same shared Keychain account/quota. - With
AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1: both empty profiles stayed isolated from Keychain and returned JSON-RPC error-32603(No browser is available here (this is a remote (SSH) session...)), requiring per-profile token storage.
- Without
- PR branch unit tests (
02f8fd0c52):vp test run apps/server/src/provider/antigravityAuthSupport.test.tspassed (31/31) on macOS arm64.
(Did not test Gemini Enterprise /
oauth-business.)- A/B isolation check against two fresh, empty
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.