GeezerVison is showing github.com — fix(server): Grok and Antigravity agents get T3CODE_THREAD_ID like other ACP agents by spoukyii · Pull Request #31901 · pingdotgg/t3code
Conversation
Problem
Grok and Antigravity agents start without T3CODE_THREAD_ID. Claude and Codex sessions set it, and #30361 added it for ACP agents, so a process the agent starts (a shell tool, an MCP server, a dev server) can find its own T3 thread even when several agents run in one directory. Grok and Antigravity run on the shared ACP adapter, one process per thread, but each drops the environment that adapter hands it.
To see it: in a Grok or Antigravity thread, ask the agent to run echo "thread=$T3CODE_THREAD_ID". On main it prints thread=. With this change it prints the thread's id, as the same prompt does in a Codex or Claude thread.
Change
The shared ACP adapter gives each flavor's makeRuntime a processEnvironment for the agent process, and #30361 put T3CODE_THREAD_ID in it. The ACP registry, fx and Kiro flavors merge it into the spawn environment. Two flavors did not:
- Grok (
packages/provider-grok/src/server/adapter.ts) spread the rest of the input and launched Grok with options.environment alone. It now merges processEnvironment over the instance environment, the same way fx and Kiro do. Grok's short-lived processes (status, skills discovery, text generation) are unchanged.
- Antigravity: the flavor passes
processEnvironment on, but AntigravityDriver.makeRuntime (apps/server/src/provider/Drivers/AntigravityDriver.ts) built the spawn input from the instance environment alone. It now layers processEnvironment over the instance environment before antigravityEnvironment applies its own credential and profile rules, so those rules still win. The input type gains the field (AntigravityRuntimeInput in AntigravityAdapterV2.ts) so the hand-off is typed. Text generation and model refresh pass no processEnvironment and are unchanged.
Like every other ACP flavor, both agents now also receive T3_ACP_MCP_ENDPOINT, T3_ACP_MCP_AUTHORIZATION, T3_ACP_MCP_NODE and, when there is one, T3_ACP_MCP_ENTRYPOINT from that object. Both already receive the bearer token in session/new; the change lets their child shells read it, as fx, Kiro and the registry already do. It also makes the documented terminal fallback work for these two agents: the ACP prompt preamble tells every ACP agent to call T3 through $T3_ACP_MCP_NODE from the terminal (packages/provider-core/src/server/orchestrationInstructions.ts), and on main that variable was missing for them.
Scope and approval
This is the same fix #30361 made for ACP agents ("ACP agents get T3CODE_THREAD_ID like Claude and Codex sessions"). #30361 put the variable in the environment every ACP flavor receives, but Grok and Antigravity never forwarded it, so the fix did not reach them. It is one defect, two ACP flavors dropping the shared environment, so they are fixed together. The change forwards an environment the adapter already builds for this purpose and changes no setting, contract or UI, so it falls under CONTRIBUTING's "very small, focused fix for an obvious bug" exception. Pi (#31870) and Muse (#31871), which are not ACP flavors, have their own PRs for the same variable.
Open #30427 (Antigravity passes GOOGLE_APPLICATION_CREDENTIALS) edits antigravityAuthSupport.ts, not the driver, so the two do not conflict, and processEnvironment never carries that variable.
Verification
- Grok: the launch tests in
apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts now register a T3 MCP session for the thread and record each spawn's environment. A new case, "launches Grok with the thread id its tools inherit", asserts T3CODE_THREAD_ID in that environment.
- Antigravity:
apps/server/src/provider/Drivers/AntigravityDriver.test.ts gains "launches a thread's agent with the thread id its tools inherit". It registers a T3 MCP session, opens that thread's session through the driver's adapter, and asserts the agent spawn's T3CODE_THREAD_ID. The harness records that value before it spawns, so the case runs on Windows too, where the fixture's shell-script agent cannot start and the file's other cases are skipped.
On main with only the test commit:
vp test run apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts -t "thread id its tools inherit"
AssertionError: expected undefined to equal 'grok-launch-test'
Tests 1 failed | 10 skipped (11)
vp test run apps/server/src/provider/Drivers/AntigravityDriver.test.ts -t "thread id its tools inherit"
- Expected
+ Received
[
- "antigravity-thread-env",
+ undefined,
]
Tests 1 failed | 4 skipped (5)
With the fix:
GrokAdapterV2.test.ts and packages/provider-grok/src/server/acpSupport.test.ts: 19 passed.
AntigravityDriver.test.ts: 1 passed, 4 skipped (Windows-skipped on main too).
AntigravityAdapterV2.test.ts: 13 passed, 1 failed. The failure, "confines file requests to the workspace of the turn in progress", fails the same way at the merge base on Windows: it looks for a raw C:\... path inside JSON.stringify output, where backslashes are escaped. It passes on Linux CI.
vp run check:changed: format, lint, knip, graphql and typecheck pass. Its test step fails only on that same Windows-only case.
What I could not check: a real Grok or Antigravity turn. I worked on Windows without either installed, so I did not see the echo above print the id in a live thread, and the new Antigravity case has not run on Linux, where the fixture agent actually starts. Port discovery also reads this variable from a listening server's environment, but it reads listener environments only off Windows, and only while a Claude or Codex agent is tracked as running (PortDiscovery.trackAgent), at startup, after such an agent exits, or while an earlier read found an agent-owned server (apps/server/src/preview/PortScanner.ts:797-801). ACP agents do not call trackAgent, so this change alone does not make every server these agents start appear under their thread. That gap is the same for every ACP agent after #30361 and is not part of this fix.
Bug: processes a Grok thread starts cannot find their T3 thread, because Grok launches without T3CODE_THREAD_ID
Bug: processes an Antigravity thread starts cannot find their T3 thread, because Antigravity launches without T3CODE_THREAD_ID
This was written with Claude Opus 5.5 in Claude Code, driven from T3 Code.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…her ACP agents
The shared ACP adapter hands every flavor a processEnvironment for the
agent process, and pingdotgg#30361 put the thread's T3CODE_THREAD_ID in it so that
shells, MCP servers and dev servers the agent starts can find their T3
thread. The ACP registry, fx and Kiro flavors merge it into the spawn
environment. Grok's runtime builder and the Antigravity driver launched
their agents with the instance environment alone, so the variable never
reached them or their tools.
Grok now merges processEnvironment into its spawn environment the same
way fx and Kiro do. The Antigravity driver layers it over the instance
environment before its credential and profile filtering, and the runtime
input type names the field.
Bug: processes a Grok thread starts cannot find their T3 thread, because Grok launches without T3CODE_THREAD_ID
Bug: processes an Antigravity thread starts cannot find their T3 thread, because Antigravity launches without T3CODE_THREAD_ID
Approvability
Verdict: Approved at 3c54c0e
Macroscope's review found this PR approvable — Grok and Antigravity now receive the existing per-thread ACP environment, allowing child processes to identify their thread and use the session’s MCP connection. The change is confined to agent launches and does not alter product defaults or permissions.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
Antigravity and Grok runtime factories now merge per-process environment values into configured environments, with per-process values taking precedence. Tests capture launch environments and check that full-access launches receive T3CODE_THREAD_ID.
Changes: Agent thread environment propagation
| Layer / File(s) |
Summary |
Antigravity environment propagation apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts, apps/server/src/provider/Drivers/AntigravityDriver.ts, apps/server/src/provider/Drivers/AntigravityDriver.test.ts |
The Antigravity runtime input now includes processEnvironment. The driver merges it with the instance environment, with input values taking precedence. The test captures the launched agent’s thread ID and compares it with the session thread ID. |
Grok environment propagation packages/provider-grok/src/server/adapter.ts, apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts |
The Grok runtime factory merges processEnvironment into the configured environment, with process values taking precedence. The test captures launch environments and checks the thread ID for a full-access launch. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- pingdotgg/t3code#26876: Renames a field in
AntigravityAcpRuntimeInput, the type from which this change derives AntigravityRuntimeInput.
Suggested labels: bugfix
Suggested reviewers: juliusmarminge
Merge Risk: Minimal · up to 3c54c
-
No actionable merge-blocking issue is established; the change is mergeable after normal checks.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title clearly identifies the thread ID fix for Grok and Antigravity agents. |
| Description check |
 |
The description covers the problem, change, scope exception, and verification results. It also identifies failed and unperformed checks and names the agent and harness. |
| Linked Issues check |
 |
No active directly linked issues remain. Issue #30361 is closed and provides historical context only, so no linked-issue coding requirements apply. |
| Out of Scope Changes check |
 |
The Grok and Antigravity environment merges address the stated thread ID fix. The runtime input type and launch tests support those changes. Forwarding the other shared ACP environment variables uses … |
Full details: Out of Scope Changes check
-
Explanation
The Grok and Antigravity environment merges address the stated thread ID fix. The runtime input type and launch tests support those changes. Forwarding the other shared ACP environment variables uses the same hand-off.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between ef81fd1 and 3c54c0e.
Files selected for processing: 5
-
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts
apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts
apps/server/src/provider/Drivers/AntigravityDriver.test.ts
apps/server/src/provider/Drivers/AntigravityDriver.ts
packages/provider-grok/src/server/adapter.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Closing this. I don't have Grok or Antigravity here, so I couldn't run a real turn and see the agent's shell print T3CODE_THREAD_ID. A unit test alone isn't enough for a change like this.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:S
10-29 changed lines (additions + deletions).
vouch:unvouched
Author is not yet trusted in the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|