Skip to content
Open
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
135 changes: 69 additions & 66 deletions apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,74 +453,77 @@ const claudeUnrelatedChildren = [

describe("AcpRegistryAdapterV2", () => {
it.effect.each([
{ commandPath: "/root/.local/bin/agy", offers: 1 },
{ commandPath: "C:\\tools\\agy.exe", offers: 1 },
{ commandPath: "/opt/bin/other-agent", offers: 0 },
])("continues late output only for agy ($commandPath)", ({ commandPath, offers }) =>
Effect.gen(function* () {
const gate = makeProviderReplayGate(["wake"]);
const update = (sessionUpdate: Record<string, unknown>) =>
claudeFrames.update(CLAUDE_ROOT_SESSION, sessionUpdate);
const session = yield* openClaudeReplaySession(
[
{
type: "expect_outbound",
frame: { kind: "request", method: "initialize", params: "<any>" },
},
{
type: "emit_inbound",
frame: {
kind: "response",
method: "initialize",
result: {
protocolVersion: 1,
agentInfo: { name: "Antigravity ACP Server", version: "1.5.9" },
agentCapabilities: { loadSession: true },
authMethods: [],
{ commandPath: "/root/.local/bin/agy", version: "1.5.11", offers: 1 },
{ commandPath: "C:\\tools\\agy.exe", version: "1.5.11", offers: 1 },
{ commandPath: "/root/.local/bin/agy", version: "1.5.9", offers: 0 },
{ commandPath: "/opt/bin/other-agent", version: "1.5.11", offers: 0 },
])(
"continues late output only for agy >= 1.5.10 ($commandPath, $version)",
({ commandPath, version, offers }) =>
Effect.gen(function* () {
const gate = makeProviderReplayGate(["wake"]);
const update = (sessionUpdate: Record<string, unknown>) =>
claudeFrames.update(CLAUDE_ROOT_SESSION, sessionUpdate);
const session = yield* openClaudeReplaySession(
[
{
type: "expect_outbound",
frame: { kind: "request", method: "initialize", params: "<any>" },
},
{
type: "emit_inbound",
frame: {
kind: "response",
method: "initialize",
result: {
protocolVersion: 1,
agentInfo: { name: "Antigravity ACP Server", version },
agentCapabilities: { loadSession: true },
authMethods: [],
},
},
},
},
claudeFrames.open[2],
claudeFrames.open[3],
claudeFrames.prompt(1)[0],
{
type: "emit_inbound",
frame: {
kind: "response",
method: "session/prompt",
result: { stopReason: "end_turn" },
claudeFrames.open[2],
claudeFrames.open[3],
claudeFrames.prompt(1)[0],
{
type: "emit_inbound",
frame: {
kind: "response",
method: "session/prompt",
result: { stopReason: "end_turn" },
},
},
},
{
...update({
sessionUpdate: "agent_message_chunk",
content: { type: "text", text: "Background work finished." },
}),
label: "wake",
},
// agy ends each reply with usage_update; this one ends before the continuation run starts.
update({ sessionUpdate: "usage_update", used: 100, size: 1000 }),
claudeMarker("late output received"),
],
gate,
true,
{ source: "local", commandPath, commandArgs: ["acp"] },
);
yield* session.runtime.startTurn(session.turnInput(1));
assert.equal((yield* session.terminal).status, "completed");
gate.release("wake");
yield* session.throughMarker("late output received");
assert.lengthOf(session.offers, offers, "late output must only wake agy");
if (offers === 0) return;
yield* session.offers[0]!.dispatchIfCurrent!(Effect.void);
yield* session.runtime.startTurn(session.turnInput(2, { continuation: true }));
yield* TestClock.adjust("3 seconds");
const continued = yield* session.until((event) => event.type === "turn.terminal");
assert.include(JSON.stringify(continued), "Background work finished.");
const terminal = continued.at(-1)!;
if (terminal.type !== "turn.terminal") throw new Error("Missing continuation terminal");
assert.equal(terminal.status, "completed");
}).pipe(Effect.provide(layerTest)),
{
...update({
sessionUpdate: "agent_message_chunk",
content: { type: "text", text: "Background work finished." },
}),
label: "wake",
},
// agy ends each reply with usage_update; this one ends before the continuation run starts.
update({ sessionUpdate: "usage_update", used: 100, size: 1000 }),
claudeMarker("late output received"),
],
gate,
true,
{ source: "local", commandPath, commandArgs: ["acp"] },
);
yield* session.runtime.startTurn(session.turnInput(1));
assert.equal((yield* session.terminal).status, "completed");
gate.release("wake");
yield* session.throughMarker("late output received");
assert.lengthOf(session.offers, offers, "late output must only wake agy");
if (offers === 0) return;
yield* session.offers[0]!.dispatchIfCurrent!(Effect.void);
yield* session.runtime.startTurn(session.turnInput(2, { continuation: true }));
yield* TestClock.adjust("3 seconds");
const continued = yield* session.until((event) => event.type === "turn.terminal");
assert.include(JSON.stringify(continued), "Background work finished.");
const terminal = continued.at(-1)!;
if (terminal.type !== "turn.terminal") throw new Error("Missing continuation terminal");
assert.equal(terminal.status, "completed");
}).pipe(Effect.provide(layerTest)),
);

it.effect.each(["approval-required", "full-access"] as const)(
Expand All @@ -541,7 +544,7 @@ describe("AcpRegistryAdapterV2", () => {
method: "initialize",
result: {
protocolVersion: 1,
agentInfo: { name: "Antigravity ACP Server", version: "1.5.9" },
agentInfo: { name: "Antigravity ACP Server", version: "1.5.11" },
agentCapabilities: { loadSession: true },
authMethods: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,7 @@ const openSessionWithRunningCommand = Effect.fn("openSessionWithRunningCommand")
options?: {
readonly profileDirectory?: string;
readonly initialToolCalls?: ReadonlyArray<EffectAcpSchema.SessionUpdate>;
readonly agentVersion?: string;
},
) {
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
Expand Down Expand Up @@ -1055,7 +1056,7 @@ const openSessionWithRunningCommand = Effect.fn("openSessionWithRunningCommand")
cwd: input.cwd,
env: {
T3_ACP_ANTIGRAVITY: "1",
...(steering === undefined ? {} : { T3_ACP_AGENT_VERSION: steering.agentVersion }),
T3_ACP_AGENT_VERSION: steering?.agentVersion ?? options?.agentVersion ?? "1.5.11",
},
},
}).pipe(
Expand Down Expand Up @@ -1349,6 +1350,24 @@ describe("AntigravityAdapterV2 work after the prompt ends", () => {
}).pipe(Effect.provide(layerSession)),
);

// agy below 1.5.10 exits its conversation update stream on end_turn and never emits a
// post-prompt completion for a backgrounded command, so holding the turn open would hang.
it.effect("completes the run on end_turn when agy below 1.5.10 leaves a command running", () =>
Effect.gen(function* () {
const { offers, startTurn, until } = yield* openSessionWithRunningCommand(
{ WaitMsBeforeAsync: 10000 },
undefined,
undefined,
{ agentVersion: "1.5.9" },
);
yield* startTurn(1, false);
const run = yield* until((event) => event.type === "turn.terminal");
const terminal = run.at(-1);
assert.equal(terminal?.type === "turn.terminal" && terminal.status, "completed");
assert.lengthOf(offers, 0);
}).pipe(Effect.provide(layerSession)),
);

// Command 2 finishes during reply 1; agy dequeues command 2 after reply 1's usage_update and
// needs >3 s before streaming reply 2. Wait for reply 2 (bounded by the 2-minute quiet limit),
// but still finalize at 3 s when both commands were batched into reply 1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
antigravityPermissionMode,
antigravityRuntimeModeForSessionMode,
antigravitySteersWithPrompt,
antigravityStreamsAfterPrompt,
applyAntigravityAcpModelSelection,
buildAntigravityPrompt,
type AntigravityAcpRuntimeInput,
Expand Down Expand Up @@ -237,10 +238,11 @@ export function makeAntigravityAcpAdapterFlavor(
),
// Loading history replays tool calls; resume avoids replay.
subagentsIdleOnTurnCompletion: true,
// A finished background command or timer wakes the agent with no prompt open: it streams a
// reply and asks for permissions, and no prompt response ever ends that reply.
enablePostSettleContinuation: true,
deferFinalizeForBackgroundWork: true,
// From agy 1.5.10, a finished background command or timer wakes the agent with no prompt open:
// it streams a reply and asks for permissions, and no prompt response ever ends that reply.
// Earlier 1.5 releases close their update stream on end_turn, so deferring finalize would hang.
enablePostSettleContinuation: antigravityStreamsAfterPrompt,
deferFinalizeForBackgroundWork: antigravityStreamsAfterPrompt,
wakeOnDetachedRequest: true,
replyEndsWithUsageUpdate: true,
toolOutlivesPrompt: antigravityToolOutlivesPrompt,
Expand Down
Loading
Loading