Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
32e45fc
fix(server): enable Antigravity subagent continuation and idle paragr…
vedmalex Nov 3, 2026
331ffff
test(orchestration): verify open-cohort sibling preservation on inter…
vedmalex Nov 3, 2026
a8ebd72
test(orchestration): assert successor wake is dispatched on open coho…
vedmalex Nov 3, 2026
8bc3d21
fix(antigravity): quarantine corrupted session checkpoints and auto-r…
vedmalex Nov 3, 2026
a3d8dc0
fix(antigravity): preserve session db atomicity on quarantine and rem…
vedmalex Nov 3, 2026
68a0867
Merge remote-tracking branch 'origin/main' into fix/antigravity-subag…
vedmalex Nov 3, 2026
976fc94
Merge remote-tracking branch 'origin/main' into fix/antigravity-subag…
vedmalex Nov 3, 2026
c9061f4
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 3, 2026
bbb9237
fix(server): narrow Antigravity continuation PR scope
vedmalex Nov 10, 2026
f8b3071
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 10, 2026
f2c967e
fix(server): type Antigravity quarantine failures
vedmalex Nov 10, 2026
66aa4c6
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 10, 2026
c6414a6
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 10, 2026
66dfb2e
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 10, 2026
3830e2b
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 12, 2026
797f830
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 12, 2026
f96660b
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 12, 2026
af8b972
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 12, 2026
096601c
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 12, 2026
4991d5e
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 13, 2026
664214f
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 13, 2026
04dbaef
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 13, 2026
c01069d
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 13, 2026
b8014cc
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 14, 2026
4436144
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 14, 2026
b76e779
fix(antigravity): forward thread MCP env and defer MCP tools
Nov 14, 2026
48f778c
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 14, 2026
449f904
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 14, 2026
283e0f7
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 15, 2026
805b550
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 15, 2026
7611562
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 16, 2026
edb7eac
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 17, 2026
c2d1346
Merge branch 'main' into fix/antigravity-subagents-continuation
vedmalex Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ export function makeAntigravityAcpAdapterFlavor(
supportsNativeGoals: options.supportsNativeGoals ?? Effect.succeed(false),
// Agents that advertise HTTP MCP skip the stdio bridge process; others keep stdio.
mcpOverHttp: true,
// Keep initial tools/list under Antigravity ACP's ~40 KB eager schema cap via tool_search.
deferMcpTools: true,
sessionCarriesPullRequestLinking: antigravityAppendsSystemPrompt,
makeRuntime,
buildAttachmentPrompt: ({
Expand Down Expand Up @@ -281,6 +283,7 @@ export function makeAntigravityAcpAdapterFlavor(
// 1.4.5 returns the root trajectory's Gemini usageMetadata delta; 1.4.1 returns none.
reportsPerTurnPromptUsage: true,
geminiPromptUsage: true,
enablePostSettleContinuation: true,
...(profileDirectory === undefined
? {}
: {
Expand Down
69 changes: 69 additions & 0 deletions apps/server/src/provider/Drivers/AntigravityDriver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
import { expect, it } from "@effect/vitest";
import {
ANTIGRAVITY_DEFAULT_MODEL,
EnvironmentId,
ProviderInstanceId,
ProviderSessionId,
ThreadId,
Expand Down Expand Up @@ -82,6 +83,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
/** `data` of the agent's "Internal error" response to `session/new`. */
readonly newSessionErrorData?: unknown;
readonly initialMode?: string;
readonly httpMcp?: boolean;
} = {},
) {
const directory = path.join(root, name);
Expand All @@ -105,6 +107,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
...(options.initialMode === undefined
? []
: [`export T3_ACP_INITIAL_MODE=${shellQuote(options.initialMode)}`]),
...(options.httpMcp ? ["export T3_ACP_MCP_HTTP=1"] : []),
`exec ${shellQuote(nodePath)} ${shellQuote(mockAgentPath)} "$@"`,
"",
].join("\n"),
Expand Down Expand Up @@ -142,6 +145,10 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
credentialKeys: ReadonlyArray<string>;
geminiApiKey: string | undefined;
tempDirectory: string | undefined;
threadId: string | undefined;
mcpEndpoint: string | undefined;
mcpAuthorization: string | undefined;
mcpNode: string | undefined;
handle: ChildProcessSpawner.ChildProcessHandle;
}> = [];

Expand Down Expand Up @@ -200,6 +207,10 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
geminiApiKey: env("GEMINI_API_KEY"),
tempDirectory:
environment.ANTIGRAVITY_HARNESS_PATH === undefined ? undefined : env("TMPDIR"),
threadId: env("T3CODE_THREAD_ID"),
mcpEndpoint: env("T3_ACP_MCP_ENDPOINT"),
mcpAuthorization: env("T3_ACP_MCP_AUTHORIZATION"),
mcpNode: env("T3_ACP_MCP_NODE"),
handle,
});
return handle;
Expand Down Expand Up @@ -579,4 +590,62 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
expect(yield* fs.exists(legacyRoot)).toBe(false);
}),
);

it.effect.skipIf(windowsHost)(
"forwards thread MCP environment and defers MCP tools for Antigravity sessions",
() =>
Effect.gen(function* () {
const h = yield* makeHarness();
h.controls.selected = yield* h.makeExecutable("runtime http mcp", { httpMcp: true });
const mcpSessions = yield* McpProviderSessions.McpProviderSessions;
const workspace = yield* h.fs.makeTempDirectoryScoped({ prefix: "t3-ag-mcp-" });
const threadId = ThreadId.make("thread-antigravity-mcp-env");
const providerSessionId = ProviderSessionId.make("provider-session-antigravity-mcp-env");
const endpoint = "http://127.0.0.1:43210/mcp";
const authorizationHeader = "Bearer test-mcp-token";
yield* mcpSessions.set({
environmentId: EnvironmentId.make("env-test"),
threadId,
providerSessionId,
providerInstanceId: h.instance.instanceId,
endpoint,
authorizationHeader,
browserToolsAvailable: false,
});
const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: workspace,
});
const modelSelection = { instanceId: h.instance.instanceId, model: "gemini-test-low" };
const session = yield* h.instance.orchestrationAdapter.openSession({
threadId,
providerSessionId,
modelSelection,
runtimePolicy,
});
yield* session.ensureThread({ threadId, modelSelection, runtimePolicy });

const launch = h.launches.at(-1);
expect(launch?.threadId).toBe(threadId);
expect(launch?.mcpEndpoint).toBe(endpoint);
expect(launch?.mcpAuthorization).toBe(authorizationHeader);
expect(launch?.mcpNode).toBeTruthy();

const newSessionRequest = (yield* h.readRequests).findLast(
(request) => request.method === "session/new",
);
expect(newSessionRequest?.params?.mcpServers).toEqual([
{
type: "http",
name: "t3-code",
url: endpoint,
headers: [
{ name: "Authorization", value: authorizationHeader },
{ name: "t3-tool-exposure", value: "deferred" },
],
},
]);
}),
);
});
7 changes: 6 additions & 1 deletion apps/server/src/provider/Drivers/AntigravityDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,12 @@ export const AntigravityDriver: ProviderDriver<
installation: executable,
profile,
cwd: input.cwd,
baseEnv: processEnvironment,
baseEnv: input.processEnvironment
? {
...processEnvironment,
...input.processEnvironment,
}
: processEnvironment,
auth,
runtimeTempDirectory,
}),
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/provider/acp/AntigravityAcpSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface AntigravityAcpRuntimeInput extends Omit<
/** Conversational sessions only; helpers and probes leave the system prompt untouched. */
readonly sessionSystemPromptAppend?: string;
readonly authMethod?: AntigravityAuthMethod;
readonly processEnvironment?: NodeJS.ProcessEnv | undefined;
}

function parseAntigravityVersion(version: string | null | undefined) {
Expand Down
63 changes: 63 additions & 0 deletions apps/server/src/provider/acp/AntigravityTurnOutcome.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,67 @@ describe("watchAntigravityPromptOutcome", () => {
});
}).pipe(Effect.provide(NodeServices.layer)),
);

it.effect("detects corrupted checkpoint errors and quarantines the database", () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const profileDirectory = yield* fs.makeTempDirectoryScoped();
const sessionId = "a1b2c3d4-e5f6-4a1b-8c2d-3e4f5a6b7c8d";
const conversations = path.join(profileDirectory, "antigravity-acp", "conversations");
yield* fs.makeDirectory(conversations, { recursive: true });
const dbPath = path.join(conversations, `${sessionId}.db`);

const database = new NodeSqlite.DatabaseSync(dbPath);
try {
database.exec(
"CREATE TABLE IF NOT EXISTS steps (idx INTEGER PRIMARY KEY, step_type INTEGER, step_payload BLOB)",
);
} finally {
database.close();
}

const check = yield* watchAntigravityPromptOutcome(profileDirectory, sessionId);

const checkpointCorruptPayload = errorPayload(
"agent executor error: could not find doneCh for checkpoint",
);
const corruptDb = new NodeSqlite.DatabaseSync(dbPath);
try {
corruptDb
.prepare("INSERT INTO steps (idx, step_type, step_payload) VALUES (?, ?, ?)")
.run(0, ERROR_MESSAGE, checkpointCorruptPayload);
} finally {
corruptDb.close();
}

const blocked = `${dbPath}.corrupt-0`;
yield* fs.makeDirectory(blocked);
const walPath = `${dbPath}-wal`;
yield* fs.writeFileString(walPath, "fixture wal");
const failed = yield* check({ stopReason: "end_turn" });
assert.equal(failed?.retryable, false);
assert.isTrue(yield* fs.exists(dbPath));
assert.isTrue(yield* fs.exists(walPath));
yield* fs.remove(blocked, { recursive: true });
yield* fs.remove(walPath);

const failure = yield* check({ stopReason: "end_turn" });
assert.deepEqual(failure, {
class: "provider_error",
message:
"Antigravity session checkpoint was corrupted and has been quarantined. The session will restart.",
code: "SESSION_CORRUPTED",
retryable: true,
});

// The original .db file should be quarantined (moved)
const originalExists = yield* fs.exists(dbPath);
assert.isFalse(originalExists);

const files = yield* fs.readDirectory(conversations);
const quarantined = files.find((f) => f.startsWith(`${sessionId}.db.corrupt-`));
assert.isDefined(quarantined);
}).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
);
});
81 changes: 80 additions & 1 deletion apps/server/src/provider/acp/AntigravityTurnOutcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const MAX_ERROR_PAYLOAD_BYTES = 16_384;
// The Go harness's rendering of a Google API error, as the agent's api_errors.py reads it.
const API_ERROR = /Error (\d{3}), Message: (.+?), Status: ([A-Z_]+)/s;
const QUOTA_EXHAUSTED = /\breason:QUOTA_EXHAUSTED\b/;
const CHECKPOINT_CORRUPTED = /could not find doneCh for checkpoint/i;

function isAntigravityCheckpointCorrupted(text: string): boolean {
return CHECKPOINT_CORRUPTED.test(text);
}

const RESET_TIMESTAMP = /\bquotaResetTimeStamp:([^\s\]]+)/;
const RESET_DELAY = /\bquotaResetDelay:((?:\d+(?:\.\d+)?(?:ns|us|µs|μs|ms|h|m|s))+)(?=[\s\]])/;
// google.rpc.RetryInfo, which plain rate limits carry instead of a quota reset.
Expand Down Expand Up @@ -53,6 +59,15 @@ class AntigravitySessionLogError extends Schema.TaggedError<AntigravitySessionLo

const sessionLogError = (cause: unknown) => new AntigravitySessionLogError({ cause });

class AntigravitySessionQuarantineError extends Schema.TaggedError<AntigravitySessionQuarantineError>()(
"AntigravitySessionQuarantineError",
{ cause: Schema.Defect() },
) {
override get message(): string {
return "Could not quarantine the Antigravity session database.";
}
}

const readSteps = <A>(file: string, read: (database: NodeSqlite.DatabaseSync) => A) =>
Effect.try({
try: () => {
Expand Down Expand Up @@ -124,6 +139,15 @@ function turnFailure(
resetAt: resetAtFrom(text, now) ?? null,
});
}
if (isAntigravityCheckpointCorrupted(text)) {
return makeProviderFailure({
class: "provider_error",
message:
"Antigravity session checkpoint was corrupted and has been quarantined. The session will restart.",
code: "SESSION_CORRUPTED",
retryable: true,
});
}
if (apiError === null) {
return makeProviderFailure({
class: "provider_error",
Expand All @@ -141,6 +165,33 @@ function turnFailure(
});
}

async function quarantineAntigravitySessionDatabase(
databasePath: string,
timestamp: number,
): Promise<string> {
const quarantinePath = `${databasePath}.corrupt-${timestamp}`;
const moved: Array<readonly [string, string]> = [];
try {
for (const suffix of ["-wal", "-shm", ""]) {
const source = `${databasePath}${suffix}`;
const destination = `${quarantinePath}${suffix}`;
try {
await NodeFSP.rename(source, destination);
moved.push([source, destination]);
} catch (error) {
if (suffix !== "" && (error as NodeJS.ErrnoException).code === "ENOENT") continue;
throw error;
}
}
} catch (error) {
for (const [source, destination] of moved.reverse()) {
await NodeFSP.rename(destination, source);
}
throw error;
}
return quarantinePath;
}

const conversationSegments = ["antigravity-acp", "conversations"];

/**
Expand Down Expand Up @@ -211,6 +262,34 @@ export const watchAntigravityPromptOutcome = Effect.fn("AntigravityTurnOutcome.w
Effect.orElseSucceed(() => undefined),
)
: undefined;
return turnFailure(result.stopReason, step, yield* DateTime.now);
const now = yield* DateTime.now;
const failure = turnFailure(result.stopReason, step, now);
if (failure?.code === "SESSION_CORRUPTED" && after !== undefined) {
const timestamp = DateTime.toEpochMillis(now);
const quarantined = yield* Effect.tryPromise({
try: () => quarantineAntigravitySessionDatabase(after.path, timestamp),
catch: (cause) => new AntigravitySessionQuarantineError({ cause }),
}).pipe(
Effect.tap(() =>
Effect.logWarning("Quarantined corrupted Antigravity session database", {
path: after.path,
}),
),
Effect.as(true),
Effect.tapError((error) =>
Effect.logWarning("Could not quarantine Antigravity session database", { error }),
),
Effect.orElseSucceed(() => false),
);
if (!quarantined) {
return makeProviderFailure({
class: "provider_error",
message: "Antigravity session checkpoint is corrupted and could not be quarantined.",
code: "SESSION_QUARANTINE_FAILED",
retryable: false,
});
}
}
return failure;
});
});
Loading