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
Still needed on agy 1.5.21 (T3-managed runtime, macOS arm64). I ran agy acp --gemini-dir --app-data-dir antigravity-acp with the environment antigravityEnvironment builds today (SSH_CONNECTION + AGY_ACP_FORCE_FILE_STORAGE=1). authenticate with oauth-personal succeeds on the empty profile, as the account in the shared keychain entry (ChainedAuth: authenticated via keyring). With AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1 added, the log shows Using file-based token storage because AGY_CLI_FORCE_FILE_TOKEN_STORAGE is set, and authenticate correctly reports the profile as not signed in. In practice: I have three oauth-personal instances on one machine. Since 1.5.20, every one of them has authenticated as whichever account signed in last. One instance ran a full day of turns on another account and quota, with nothing in the UI to show it.
Quick triage note: the bot's
cannot-proveblockers from Nov 23 are now stale.- Personal sign-in + usage limits: Usage limits were removed on Nov 25, and five users independently verified macOS/Linux isolation up through
agy1.5.21. - Gemini Enterprise: Untouched aside from stripping the new env var for
oauth-business(unit-tested).
Looks ready for a human merge.
- Personal sign-in + usage limits: Usage limits were removed on Nov 25, and five users independently verified macOS/Linux isolation up through
Confirming the root cause still holds on T3 Code Nightly
0.1.14-nightly.20261203.5637(macOS arm64) withagy1.5.22, the build where limits come back throughagy usage --json.- Before:
acp-server-*.logshowedChainedAuth: authenticated via keyring, noantigravity-oauth-tokenin the profile, and Usage → Limits showed "Sign in with Google to see Antigravity limits." Runningagy usage --jsonby hand returnedSUCCESS. - After adding
AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1as a provider env var, then signing out and back in, the profile wroteantigravity-oauth-tokenand Usage → Limits showed all four Antigravity buckets.
So setting this variable, which is what this PR does, fixes it on 1.5.22. I tested the env-var workaround, not this branch.
- Before:
Heads-up before merging: after #47750 landed on
main, this PR currently merges cleanly without conflicts, but it does not yet setAGY_CLI_FORCE_FILE_TOKEN_STORAGE: "1"inantigravityUsageEnvironment(apps/server/src/provider/antigravityAuthSupport.ts).Because this PR adds
"AGY_CLI_FORCE_FILE_TOKEN_STORAGE"toremovedEnvironmentKeyswhile only setting it inantigravityEnvironment:antigravityUsageEnvironment(used bymakeAntigravityUsageProbeto runagy usage --jsonunder<profile>/usage-home) still only setsSSH_CONNECTIONandAGY_ACP_FORCE_FILE_STORAGE: "1", and will now strip any user-configuredAGY_CLI_FORCE_FILE_TOKEN_STORAGE=1workaround too.- In managed Antigravity
1.5.22on macOS (darwin-arm64),usagegoes through the samecodeassistclient.NewCompositeTokenStorage(store.cliTokenStorage->auth.NewCLITokenStorage):codeassistclient.forceFileFromEnvonly checksAGY_CLI_FORCE_FILE_TOKEN_STORAGE(ignoresAGY_ACP_FORCE_FILE_STORAGE).codeassistclient.sshDetector.Detectspecial-casesdarwinby callingprobeDarwinKeychainUnlocked(/usr/bin/security show-keychain-info) and returning!unlocked, which isfalseon an unlocked macOS desktop session.
- As a result, merging this PR as-is will still leave
agy usage --jsonon macOS reading the shared Login Keychain (gemini/antigravity) instead of<profile>/usage-home/.gemini/antigravity-cli/antigravity-oauth-token:- For a profile signed in with file storage (no matching Keychain entry),
agy usage --jsonwill exit withPlease sign in to view account usage., whichantigravityUsageLimits.tsmaps right back to"Sign in with Google to see Antigravity limits."— and the manual provider env-var workaround will no longer pass through. - If another account exists in macOS Keychain,
agy usage --jsonwill report that Keychain account's limits instead of the isolated profile's.
- For a profile signed in with file storage (no matching Keychain entry),
(The manual
AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1provider env-var workaround works onmaintoday only becauseAGY_CLI_FORCE_FILE_TOKEN_STORAGEis not inremovedEnvironmentKeysyet, so it passes through to bothantigravityEnvironmentandantigravityUsageEnvironment.)Adding
AGY_CLI_FORCE_FILE_TOKEN_STORAGE: "1"toantigravityUsageEnvironmentalongsideantigravityEnvironment(plus a unit test inantigravityAuthSupport.test.ts) before merging should close the gap completely for #41973 and #47750.It doesn't feel very appropriate to degrade the security for every user by default solely to support multi-accounts users.
Those multi-account users are likely using this to dodge the terms of service and usage limits making this even more morally grey.
This should probably be optional..
Using multiple accounts doesn't appear to be against the ToS as long as they are yours. There's plenty of legitimate reasons to do it. Other vendors have tweeted the same for their products.There are problems if I get the GOOGLE AI PRO subscription on my secondary Google account?ai.google.devOn Dec 3, 2026, at 7:45 AM, Jean Francois Pambrun @.***> wrote:jpambrun left a comment (pingdotgg/t3code#41982) It doesn't feel very appropriate to degrade the security for every user by default solely to support multi-accounts users. Those multi-account users are likely using this to dodge the terms of service and usage limits making this even more morally grey. This should probably be optional..
—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today! You are receiving this because you commented.Message ID: @.***>
KiritoXDone(GitHub profile, opens in a new tab) approved these changes
I support the change to use the selected instance’s credential file for personal Google sign-in. I reproduced the problem on macOS arm64 with T3 Code Nightly
0.1.14-nightly.20261203.5664andagy 1.5.23. A fresh sign-in succeeded through Keychain, but the instance had noantigravity-oauth-tokenand T3 reported zero quota windows.I set
AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1on that provider instance and signed in again. The instance token file appeared, and the running T3 server reported all four windows: 5-hour and weekly for both Gemini and Claude/GPT. This was a test of the workaround on the published Nightly. I reviewed the diff at02f8fd0separately.One detail matters when bringing this onto current
main: please also set the flag inantigravityUsageEnvironmentfor the personal account’sagy usage --jsonprocess and cover that path in a regression test. The shared environment filter in this patch would otherwise strip the flag from that process, including a value set by the user. That would let the quota lookup select a different credential store from the one used for sign-in.
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.