Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -39,7 +39,7 @@ import { readAntigravityClientTextFile } from "../../provider/acp/AntigravityCli
import { watchAntigravityPromptOutcome } from "../../provider/acp/AntigravityTurnOutcome.ts";
import {
antigravityApprovalOptions,
antigravityCommandOutlivesPrompt,
antigravityToolOutlivesPrompt,
antigravitySubagentOutput,
classifyAntigravitySubagentToolCall,
extractAntigravityUserInputQuestion,
Expand Down Expand Up @@ -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,
Expand Down
44 changes: 44 additions & 0 deletions apps/server/src/provider/acp/AntigravityProtocol.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
extractAntigravityUserInputQuestion,
antigravityApprovalOptions,
antigravitySubagentOutput,
antigravityToolOutlivesPrompt,
classifyAntigravitySubagentToolCall,
isAntigravityUserInputRequest,
makeAntigravityUserInputResponse,
Expand Down Expand Up @@ -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}`;
Expand Down
10 changes: 7 additions & 3 deletions apps/server/src/provider/acp/AntigravityProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading