diff --git a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts index 37a859fb774f3..77ab7136e678d 100644 --- a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts @@ -39,7 +39,7 @@ import { readAntigravityClientTextFile } from "../../provider/acp/AntigravityCli import { watchAntigravityPromptOutcome } from "../../provider/acp/AntigravityTurnOutcome.ts"; import { antigravityApprovalOptions, - antigravityCommandOutlivesPrompt, + antigravityToolOutlivesPrompt, antigravitySubagentOutput, classifyAntigravitySubagentToolCall, extractAntigravityUserInputQuestion, @@ -242,7 +242,7 @@ export function makeAntigravityAcpAdapterFlavor( deferFinalizeForBackgroundWork: true, wakeOnDetachedRequest: true, replyEndsWithUsageUpdate: true, - toolOutlivesPrompt: antigravityCommandOutlivesPrompt, + toolOutlivesPrompt: antigravityToolOutlivesPrompt, // session/cancel ends the agent's running commands, so only Stop sends it once the prompt // has ended. A message sent while a command runs leaves the command alone. preserveRuntimeOnSettledInterrupt: true, diff --git a/apps/server/src/provider/acp/AntigravityProtocol.test.ts b/apps/server/src/provider/acp/AntigravityProtocol.test.ts index 2b591d1490821..cfe47280fc4f1 100644 --- a/apps/server/src/provider/acp/AntigravityProtocol.test.ts +++ b/apps/server/src/provider/acp/AntigravityProtocol.test.ts @@ -7,6 +7,7 @@ import { extractAntigravityUserInputQuestion, antigravityApprovalOptions, antigravitySubagentOutput, + antigravityToolOutlivesPrompt, classifyAntigravitySubagentToolCall, isAntigravityUserInputRequest, makeAntigravityUserInputResponse, @@ -491,6 +492,49 @@ describe("Antigravity tool results", () => { expect(JSON.stringify(event.rawPayload)).not.toContain("formatted_output"); }); + it.each([ + { name: "a command", update: commandStarted.update, outlives: true }, + { + name: "a daemon", + update: { ...commandStarted.update, rawInput: { CommandLine: "serve", IsDaemon: true } }, + outlives: false, + }, + // agy 1.5.13 keeps this call in progress until the wake fires. + { + name: "a scheduled wake", + update: { + sessionUpdate: "tool_call", + toolCallId: "call_4902666363527503248", + status: "in_progress", + kind: "other", + title: "Run schedule", + rawInput: { DurationSeconds: 30, Prompt: "Reply only with the word DONE." }, + }, + outlives: true, + }, + { + name: "another native tool", + update: { + sessionUpdate: "tool_call", + toolCallId: "call_other", + status: "in_progress", + kind: "other", + title: "Run list_dir", + rawInput: { DirectoryPath: "/workspace" }, + }, + outlives: false, + }, + ] satisfies ReadonlyArray<{ + name: string; + update: EffectAcpSchema.SessionNotification["update"]; + outlives: boolean; + }>)("knows whether $name outlives the prompt", ({ update, outlives }) => { + const event = parseToolUpdate({ sessionId: "session-1", update }); + expect(antigravityToolOutlivesPrompt(normalizeAntigravityToolCall(event.toolCall))).toBe( + outlives, + ); + }); + it("keeps 1.5 command input and output valid Unicode when cut", () => { const tail = `${"x".repeat(7_982)}build completed\r\n`; const output = `Command output:\nprefix\r\nšŸš€${tail}`; diff --git a/apps/server/src/provider/acp/AntigravityProtocol.ts b/apps/server/src/provider/acp/AntigravityProtocol.ts index 33bd101589633..2ba17c8a86db5 100644 --- a/apps/server/src/provider/acp/AntigravityProtocol.ts +++ b/apps/server/src/provider/acp/AntigravityProtocol.ts @@ -45,11 +45,15 @@ const decodeSingleAnswer = Schema.decodeUnknownOption( ); const decodeToolCallContent = Schema.decodeUnknownOption(AcpWireSchema.ToolCallContent); +// agy keeps its own `schedule` call in progress until the wake fires, then replies by itself. +const ANTIGRAVITY_SCHEDULE_TITLES = new Set(["Run schedule", "Running schedule"]); + /** - * The agent goes on running a command after its prompt ends, and replies by itself when the - * command finishes. A daemon may never finish. + * The agent goes on running a command or a scheduled wake after its prompt ends, and replies by + * itself when it finishes. A daemon may never finish. */ -export function antigravityCommandOutlivesPrompt(toolCall: AcpToolCallState): boolean { +export function antigravityToolOutlivesPrompt(toolCall: AcpToolCallState): boolean { + if (toolCall.title !== undefined && ANTIGRAVITY_SCHEDULE_TITLES.has(toolCall.title)) return true; const input = toolCall.data.rawInput; return toolCall.kind === "execute" && !(Predicate.isObject(input) && input.IsDaemon === true); }