fix(antigravity): thread sessions spawn with their T3 thread and MCP environment #36495
main fromrefs/pull/36495/head·merged by maria-rcks View on GitHubProblem#
Antigravity thread sessions spawned their agent without T3CODE_THREAD_ID, T3_ACP_MCP_ENDPOINT, T3_ACP_MCP_AUTHORIZATION, T3_ACP_MCP_NODE and T3_ACP_MCP_ENTRYPOINT.
acpMcpContext builds those variables for every ACP thread and the adapter forwards them as processEnvironment, but AntigravityDriver.makeRuntime built the agent's environment from the provider instance alone, so they never reached the spawn.
Found in a live macOS T3 Code session running agy 1.5.8 on a Gemini Enterprise (oauth-business) account: the org's mcp_controls stripped the native t3-code MCP server from session/new, so the agent had no MCP tools, and the documented terminal fallback ("$T3_ACP_MCP_NODE" … acp-mcp-call …) failed too because those five variables were unset in agy acp's shell.
Change#
AntigravityAdapterV2Options["makeRuntime"]andAntigravityDriver.makeRuntimeaccept the optionalprocessEnvironmentthe ACP adapter already passes to each flavor.AntigravityAcpRuntimeInputstays untouched, somakeAntigravityAcpRuntimeis never handed an option it ignores.AntigravityDriver.makeRuntimepulls it out of the runtime input and merges it over the instance environment intobaseEnvforbuildAntigravityAcpSpawnInput. The spawn runs withextendEnv: false, so anything not inbaseEnvnever reaches the agent's shell.- Model refresh, sign-in and title-generation launches pass no
processEnvironment, so they keep starting from the instance environment alone.
Scope#
Small fix for an obvious bug, so no issue. One problem only; the same merge already exists in the fx, kiro and ACP registry flavors, and Grok's is covered by #34032.
Verification#
The new case gives a thread session its own T3 thread and MCP fallback environment in apps/server/src/provider/Drivers/AntigravityDriver.test.ts registers an McpProviderSessions entry for a thread, opens the thread with orchestrationAdapter.openSession + ensureThread, and reads the environment the harness's ChildProcessSpawner captures:
- the thread launch carries the thread's
T3CODE_THREAD_ID,T3_ACP_MCP_ENDPOINT,T3_ACP_MCP_AUTHORIZATION,T3_ACP_MCP_NODEandT3_ACP_MCP_ENTRYPOINT, each overriding an ambient instance value; - the model-refresh launch keeps the ambient values and none of the thread's.
With only AntigravityDriver.ts stashed, pnpm exec vp test run apps/server/src/provider/Drivers/AntigravityDriver.test.ts -t "gives a thread session" fails with the thread launch still holding thread-antigravity-ambient, http://127.0.0.1:9/ambient, Bearer ambient-token, /ambient/node and /ambient/entrypoint.mjs; with the fix restored, the full test file and pnpm exec vp run check:changed (format, lint, knip, graphql, typecheck and affected tests) succeed.
Live end-to-end check from this branch on macOS with real agy 1.5.8 (oauth-business / Gemini Enterprise, where org mcp_controls strips native MCP servers): started node apps/server/src/bin.ts serve on an isolated --base-dir and loopback port with T3CODE_THREAD_ID and T3_ACP_MCP_* stripped from the server's parent environment and binaryPath set directly to agy (no wrapper), added a scratch git repo with t3 project add, and ran t3 thread start --provider antigravity --wait --json asking the agent to check its shell environment and invoke "$T3_ACP_MCP_NODE" "$T3_ACP_MCP_ENTRYPOINT" acp-mcp-call orchestrator_capabilities '{}'. The turn completed (exit 0) with T3CODE_THREAD_ID matching the launched thread (mcp:62ee0ceb-d1aa-4b0e-8655-b5aff565a63c), all four T3_ACP_MCP_* variables (ENDPOINT, AUTHORIZATION, NODE, ENTRYPOINT) present in agy's shell, and orchestrator_capabilities returning isError=false.
Not checked: a packaged Electron desktop build from this branch, and Windows (skipIf(windowsHost): the unit test harness uses a POSIX #!/bin/sh fake binary).
deepseek/deepseek-flash (OpenCode)
- 1
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
f0c1ef7Macroscope's review found this PR approvable — Antigravity sessions now inherit their existing T3 thread and MCP environment when the agent process starts. The change is confined to session spawning and preserves the environment behavior of launches without thread context.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review.
Walkthrough
-
The Antigravity runtime input now accepts an optional process environment. The driver uses that environment for ACP child-process launches when supplied, and otherwise uses its own environment. Tests verify thread-specific MCP variables and retention of ambient values on a refresh launch.
Changes: Antigravity runtime environment
Layer / File(s) Summary Runtime environment input and launch
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts,apps/server/src/provider/Drivers/AntigravityDriver.tsThe adapter runtime input adds optional processEnvironment. The driver merges supplied values over its process environment for the ACP spawn base environment, or uses its process environment when the option is omitted. The authorization-error check now readsonAuthorizationUrlfromruntimeInput.Environment launch tests
apps/server/src/provider/Drivers/AntigravityDriver.test.tsThe test harness accepts extra environment variables and records complete launch environments. A test checks that the thread launch receives the registered thread ID and MCP values, while the earlier refresh launch retains ambient values. It also checks that both agent launches are recorded and closed. Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
juliusmarminge,t3dotgg
Merge Risk:
Minimal · up tof0c1e-
This change passes thread-specific T3 and MCP environment variables to Antigravity thread sessions. Other launches keep the existing environment. No concrete merge-blocking risk remains.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the fix (thread sessions spawn with their T3 thread and MCP environment) and matches the changeset: AntigravityDriver.makeRuntime now merges the thread's processEnvironment (T3CODE_THR… Description check The description follows the template's Problem, Change, Scope and Verification sections. The Problem section states the missing variables and the observed failure. The Change section explains the merg… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Title check
-
Explanation
The title names the fix (thread sessions spawn with their T3 thread and MCP environment) and matches the changeset: AntigravityDriver.makeRuntime now merges the thread's processEnvironment (T3CODE_THREAD_ID and T3_ACP_MCP_* variables) into the agent spawn environment. It is conventional-commit formatted and specific. It is 80 characters, which is slightly long but acceptable.
Full details: Description check
-
Explanation
The description follows the template's Problem, Change, Scope and Verification sections. The Problem section states the missing variables and the observed failure. The Change section explains the merge into baseEnv and the unchanged non-thread launches. The Scope section says it is a small bug fix and gives a reason for no issue. The Verification section lists the new test, the stash-based failure check, the full test run, and a live macOS check, and it names what was not checked. Two minor gaps: the Scope section does not link an issue, and the template's closing agent-attribution line is present but reads as a model name rather than a full model and harness statement. These gaps are non-critical.
-
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-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: e5835c9
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
3f5007d6-1869-43a7-a1eb-e95d093d96ea
Commits-
Reviewing files that changed from the base of the PR and between e5835c993a6af969088d1c8fe62278f711852b0a and f0c1ef7152c17dcb4f31e3dcdee5054807bbb001.
Files selected for processing: 3-
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.tsapps/server/src/provider/Drivers/AntigravityDriver.test.tsapps/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.
-
-
Note
Written by
gpt-6.1-solon behalf of MariaVerified in a real dev environment#
verified the process-environment fix at
f0c1ef7152c17dcb4f31e3dcdee5054807bbb001againstgithub/mainat2d558c4dad93f59cd03b5c3c9b3372555a503c84on linux. used separate isolated data, one dev server at a time, the official antigravity 1.5.11 runtime, and a real git project added through the web app.- reproduced main's bug through
t3 thread start --provider antigravity --model antigravity-default --wait --json: the real antigravity child process lacked all five thread/MCP variables. - on this head, the same launch carried
T3CODE_THREAD_IDmatching its actual thread, plusT3_ACP_MCP_ENDPOINT,T3_ACP_MCP_AUTHORIZATION,T3_ACP_MCP_NODE, andT3_ACP_MCP_ENTRYPOINT. inspected the actual process environment without recording secrets. - while that process was starting, the application's real
AcpMcpStdioBridge.mcpToolSession, using the endpoint and authorization from that process, calledorchestrator_capabilitiessuccessfully:isError=false, matching antigravity thread. this was an external probe of the live credentials, not a signed-in model invoking the fallback. - checked the neighboring sign-in launch through settings: its real process still had none of these thread variables.
- real web-client turns with codex
gpt-6.1-solcompleted on main and this head. a follow-up on this head called the nativet3-code/orchestrator_capabilitiestool successfully; confirmed its completed provider event and the rendered reply. - blacksmith:
vp test run apps/server/src/provider/Drivers/AntigravityDriver.test.tspassed all 7 tests. existing CI reports 35 successful checks, 0 failing, 0 pending. no source changes or pushes were needed.

Not verified#
a completed authenticated antigravity turn, an agent-invoked terminal fallback, and gemini enterprise's native MCP stripping remain unverified. this vm has no google login or gemini API credential. both versions reach the real runtime and fail google authentication. a standalone CLI fallback attempt outlived the failed session and received HTTP 401; preloading the same bridge allowed the live credential check before cleanup.
packaged electron, native ios/android, macos, and windows were not exercised on this linux vm.

- reproduced main's bug through
maria-rcks merged thisc67deb1
maria-rcks closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes