Skip to content

Commit b76e779

Browse files
Алексей ВедмеденкоАлексей Ведмеденко
authored andcommitted
fix(antigravity): forward thread MCP env and defer MCP tools
AntigravityDriver dropped input.processEnvironment when building the ACP spawn env, hiding T3CODE_THREAD_ID and T3_ACP_MCP_* from Antigravity's built-in shell tool. AntigravityAdapterV2 also omitted deferMcpTools, causing Antigravity ACP's ~40 KB eager schema cap to drop delegate_task, t3_thread_launch, and schedule_task. Merge input.processEnvironment into baseEnv in AntigravityDriver and enable deferMcpTools on AntigravityAdapterV2 so initial tools/list stays under the cap via tool_search (refs pingdotgg#36088). Authored with Gemini 4 Hydrogen via Antigravity.
1 parent 4436144 commit b76e779

4 files changed

Lines changed: 78 additions & 1 deletion

File tree

‎apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ export function makeAntigravityAcpAdapterFlavor(
212212
supportsNativeGoals: options.supportsNativeGoals ?? Effect.succeed(false),
213213
// Agents that advertise HTTP MCP skip the stdio bridge process; others keep stdio.
214214
mcpOverHttp: true,
215+
// Keep initial tools/list under Antigravity ACP's ~40 KB eager schema cap via tool_search.
216+
deferMcpTools: true,
215217
sessionCarriesPullRequestLinking: antigravityAppendsSystemPrompt,
216218
makeRuntime,
217219
buildAttachmentPrompt: ({

‎apps/server/src/provider/Drivers/AntigravityDriver.test.ts‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
33
import { expect, it } from "@effect/vitest";
44
import {
55
ANTIGRAVITY_DEFAULT_MODEL,
6+
EnvironmentId,
67
ProviderInstanceId,
78
ProviderSessionId,
89
ThreadId,
@@ -82,6 +83,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
8283
/** `data` of the agent's "Internal error" response to `session/new`. */
8384
readonly newSessionErrorData?: unknown;
8485
readonly initialMode?: string;
86+
readonly httpMcp?: boolean;
8587
} = {},
8688
) {
8789
const directory = path.join(root, name);
@@ -105,6 +107,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
105107
...(options.initialMode === undefined
106108
? []
107109
: [`export T3_ACP_INITIAL_MODE=${shellQuote(options.initialMode)}`]),
110+
...(options.httpMcp ? ["export T3_ACP_MCP_HTTP=1"] : []),
108111
`exec ${shellQuote(nodePath)} ${shellQuote(mockAgentPath)} "$@"`,
109112
"",
110113
].join("\n"),
@@ -142,6 +145,10 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
142145
credentialKeys: ReadonlyArray<string>;
143146
geminiApiKey: string | undefined;
144147
tempDirectory: string | undefined;
148+
threadId: string | undefined;
149+
mcpEndpoint: string | undefined;
150+
mcpAuthorization: string | undefined;
151+
mcpNode: string | undefined;
145152
handle: ChildProcessSpawner.ChildProcessHandle;
146153
}> = [];
147154

@@ -200,6 +207,10 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
200207
geminiApiKey: env("GEMINI_API_KEY"),
201208
tempDirectory:
202209
environment.ANTIGRAVITY_HARNESS_PATH === undefined ? undefined : env("TMPDIR"),
210+
threadId: env("T3CODE_THREAD_ID"),
211+
mcpEndpoint: env("T3_ACP_MCP_ENDPOINT"),
212+
mcpAuthorization: env("T3_ACP_MCP_AUTHORIZATION"),
213+
mcpNode: env("T3_ACP_MCP_NODE"),
203214
handle,
204215
});
205216
return handle;
@@ -579,4 +590,62 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
579590
expect(yield* fs.exists(legacyRoot)).toBe(false);
580591
}),
581592
);
593+
594+
it.effect.skipIf(windowsHost)(
595+
"forwards thread MCP environment and defers MCP tools for Antigravity sessions",
596+
() =>
597+
Effect.gen(function* () {
598+
const h = yield* makeHarness();
599+
h.controls.selected = yield* h.makeExecutable("runtime http mcp", { httpMcp: true });
600+
const mcpSessions = yield* McpProviderSessions.McpProviderSessions;
601+
const workspace = yield* h.fs.makeTempDirectoryScoped({ prefix: "t3-ag-mcp-" });
602+
const threadId = ThreadId.make("thread-antigravity-mcp-env");
603+
const providerSessionId = ProviderSessionId.make("provider-session-antigravity-mcp-env");
604+
const endpoint = "http://127.0.0.1:43210/mcp";
605+
const authorizationHeader = "Bearer test-mcp-token";
606+
yield* mcpSessions.set({
607+
environmentId: EnvironmentId.make("env-test"),
608+
threadId,
609+
providerSessionId,
610+
providerInstanceId: h.instance.instanceId,
611+
endpoint,
612+
authorizationHeader,
613+
browserToolsAvailable: false,
614+
});
615+
const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
616+
runtimeMode: "approval-required",
617+
interactionMode: "default",
618+
cwd: workspace,
619+
});
620+
const modelSelection = { instanceId: h.instance.instanceId, model: "gemini-test-low" };
621+
const session = yield* h.instance.orchestrationAdapter.openSession({
622+
threadId,
623+
providerSessionId,
624+
modelSelection,
625+
runtimePolicy,
626+
});
627+
yield* session.ensureThread({ threadId, modelSelection, runtimePolicy });
628+
629+
const launch = h.launches.at(-1);
630+
expect(launch?.threadId).toBe(threadId);
631+
expect(launch?.mcpEndpoint).toBe(endpoint);
632+
expect(launch?.mcpAuthorization).toBe(authorizationHeader);
633+
expect(launch?.mcpNode).toBeTruthy();
634+
635+
const newSessionRequest = (yield* h.readRequests).findLast(
636+
(request) => request.method === "session/new",
637+
);
638+
expect(newSessionRequest?.params?.mcpServers).toEqual([
639+
{
640+
type: "http",
641+
name: "t3-code",
642+
url: endpoint,
643+
headers: [
644+
{ name: "Authorization", value: authorizationHeader },
645+
{ name: "t3-tool-exposure", value: "deferred" },
646+
],
647+
},
648+
]);
649+
}),
650+
);
582651
});

‎apps/server/src/provider/Drivers/AntigravityDriver.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ export const AntigravityDriver: ProviderDriver<
276276
installation: executable,
277277
profile,
278278
cwd: input.cwd,
279-
baseEnv: processEnvironment,
279+
baseEnv: input.processEnvironment
280+
? {
281+
...processEnvironment,
282+
...input.processEnvironment,
283+
}
284+
: processEnvironment,
280285
auth,
281286
runtimeTempDirectory,
282287
}),

‎apps/server/src/provider/acp/AntigravityAcpSupport.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export interface AntigravityAcpRuntimeInput extends Omit<
5050
/** Conversational sessions only; helpers and probes leave the system prompt untouched. */
5151
readonly sessionSystemPromptAppend?: string;
5252
readonly authMethod?: AntigravityAuthMethod;
53+
readonly processEnvironment?: NodeJS.ProcessEnv | undefined;
5354
}
5455

5556
function parseAntigravityVersion(version: string | null | undefined) {

0 commit comments

Comments
 (0)