From 20f217b8cb19e0b438385fddc25373b178c83c59 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Sun, 22 Nov 2026 11:11:55 +0700 Subject: [PATCH] fix(acp): finish Antigravity turns after recurring schedules (#10469) Antigravity returns end_turn while a recurring schedule stays in progress. Exclude cron registration from the provider's deferred-turn blockers so waiting for a tool completion cannot strand the foreground turn. --- .../server/provider.test.ts | 86 ++++++++++++++++++- .../antigravity-provider/server/provider.ts | 13 ++- 2 files changed, 94 insertions(+), 5 deletions(-) diff --git a/plugins/antigravity-provider/server/provider.test.ts b/plugins/antigravity-provider/server/provider.test.ts index d3c263a4e..7483600ec 100644 --- a/plugins/antigravity-provider/server/provider.test.ts +++ b/plugins/antigravity-provider/server/provider.test.ts @@ -49,7 +49,9 @@ it("publishes Antigravity skills separately from built-in commands", async () => send({ id, result: { protocolVersion: 1 } }); } if (method === "session/new") { - send({ id, result: { sessionId: "native" } }); + send({ id, result: { sessionId: "native", modes: { + currentModeId: "default", availableModes: [{ id: "default", name: "Default" }], + } } }); send({ method: "session/update", params: { sessionId: "native", update: { sessionUpdate: "available_commands_update", availableCommands: ["goal", "compact", "schedule", "browser", "plan", "grill-me", @@ -500,6 +502,88 @@ describe("installation", () => { }); }); +it("completes the turn when a recurring schedule stays in progress after end_turn", async () => { + const { directory, launch } = await launchAgent(` + const { createInterface } = require("node:readline"); + const send = (message) => process.stdout.write(JSON.stringify({ jsonrpc: "2.0", ...message }) + "\\n"); + createInterface({ input: process.stdin }).on("line", (line) => { + const { id, method } = JSON.parse(line); + const update = (update) => send({ method: "session/update", params: { sessionId: "agy-session", update } }); + switch (method) { + case "initialize": + send({ id, result: { protocolVersion: 1 } }); + break; + case "session/new": + send({ id, result: { sessionId: "agy-session", modes: { + currentModeId: "default", availableModes: [{ id: "default", name: "Default" }], + } } }); + update({ sessionUpdate: "available_commands_update", availableCommands: [] }); + break; + case "session/prompt": { + const args = { CronExpression: "*/15 * * * *", Prompt: "ping" }; + update({ sessionUpdate: "usage_update", used: 12725, size: 1048576 }); + update({ + sessionUpdate: "tool_call", toolCallId: "cron", name: "schedule", + args, status: "in_progress", kind: "other", title: "Run schedule", rawInput: args, + }); + update({ sessionUpdate: "usage_update", used: 12915, size: 1048576 }); + send({ id, result: { stopReason: "end_turn" } }); + break; + } + case "session/close": + send({ id, result: {} }); + break; + } + }); + `); + const connection = await createAntigravityProvider().connect({ + launch, + versions: [1], + capabilities: ["prompt.message"], + }); + const events: ProviderEvent[] = []; + connection.onEvent((event) => events.push(event)); + try { + await connection.send({ + type: "session.open", + requestId: "open", + sessionId: "test", + history: "skip", + config: { cwd: directory, env: {}, mcpServers: {}, settings: {}, persist: false }, + }); + await expect + .poll(() => events) + .toContainEqual(expect.objectContaining({ type: "session.ready", sessionId: "test" })); + await connection.send({ + type: "session.prompt", + sessionId: "test", + prompt: { + clientMessageId: "schedule-turn", + delivery: "auto", + input: { type: "message", content: [{ type: "text", text: "Schedule a recurring ping" }] }, + }, + }); + await expect + .poll(() => events) + .toContainEqual( + expect.objectContaining({ + type: "timeline.item", + item: expect.objectContaining({ type: "tool_call", id: "cron", status: "running" }), + }), + ); + await expect + .poll(() => events) + .toContainEqual({ + type: "session.turn", + sessionId: "test", + turnId: "acp:schedule-turn", + state: "completed", + }); + } finally { + await connection.close(); + } +}); + it("keeps a turn open for backgrounded run_command calls but not IsDaemon commands", async () => { const { directory, launch } = await launchAgent(` const { createInterface } = require("node:readline"); diff --git a/plugins/antigravity-provider/server/provider.ts b/plugins/antigravity-provider/server/provider.ts index 672bea6c2..2726a5521 100644 --- a/plugins/antigravity-provider/server/provider.ts +++ b/plugins/antigravity-provider/server/provider.ts @@ -100,10 +100,15 @@ export function createAntigravityProvider(): ProviderRegistration { deferTurnOnRunningTools: { keepsTurnOpen(toolCall) { const input = toolCall.input; - if (typeof input === "object" && input !== null && !Array.isArray(input)) { - return input.IsDaemon !== true; - } - return true; + if (typeof input !== "object" || input === null || Array.isArray(input)) return true; + if (input.IsDaemon === true) return false; + + // agy leaves recurring schedules in progress after registering them. + const recurringSchedule = + toolCall.name === "schedule" && + typeof input.CronExpression === "string" && + input.CronExpression.trim().length > 0; + return !recurringSchedule; }, }, autoAcceptMode: {