Skip to content
Closed
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
129 changes: 129 additions & 0 deletions apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,135 @@ describe("AcpAdapterV2", () => {
}).pipe(Effect.provide(layerTest), Effect.scoped),
);

it.effect("shows a flavor's notice chunk as its own item between assistant segments", () =>
Effect.gen(function* () {
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const path = yield* Path.Path;
const selfInvocation = yield* resolveSelfInvocation();
const mockAgentPath = yield* path.fromFileUrl(
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
const promptStarted = yield* Deferred.make<void>();
const promptGate = yield* Deferred.make<EffectAcpSchema.PromptResponse>();
const instanceId = ProviderInstanceId.make("acp-test-v2-notice");
const adapter = yield* makeAcpAdapterV2({
instanceId,
flavor: {
driver: ACP_TEST_DRIVER,
capabilities: AcpProviderCapabilitiesV2,
extractSystemNotice: ({ update }) =>
update.sessionUpdate === "agent_thought_chunk" && update._meta?.notice === "stop-1"
? { id: "stop-1", message: "Fix the tests." }
: undefined,
makeRuntime: makeMockRuntime({
childProcessSpawner,
mockAgentPath,
wrapRuntime: (runtime) => ({
...runtime,
handleSessionUpdate: (handler) =>
Effect.sync(() => {
sessionUpdateHandler = handler;
}).pipe(Effect.andThen(runtime.handleSessionUpdate(handler))),
prompt: () =>
Deferred.succeed(promptStarted, undefined).pipe(
Effect.andThen(Deferred.await(promptGate)),
),
}),
}),
},
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-v2-notice");
const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
});
const modelSelection = { instanceId, model: "default" } as const;
const runtime = yield* adapter.openSession({
threadId,
providerSessionId: ProviderSessionId.make("provider-session-acp-v2-notice"),
modelSelection,
runtimePolicy,
});
const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
);
const providerThread = yield* runtime.ensureThread({
threadId,
modelSelection,
runtimePolicy,
});
yield* runtime
.startTurn(
makeTurnInput({
threadId,
providerThread,
instanceId,
runtimePolicy,
now: yield* DateTime.now,
ordinal: 1,
}),
)
.pipe(Effect.forkScoped);
yield* Deferred.await(promptStarted);
if (sessionUpdateHandler === undefined) {
return yield* Effect.die("session update handler must be wired");
}
const send = sessionUpdateHandler;
yield* send({
sessionId: "mock-session-1",
update: { sessionUpdate: "agent_message_chunk", content: { type: "text", text: "Done." } },
});
yield* send({
sessionId: "mock-session-1",
update: {
sessionUpdate: "agent_thought_chunk",
content: { type: "text", text: "Stop hook feedback: Fix the tests." },
_meta: { notice: "stop-1" },
},
});
yield* send({
sessionId: "mock-session-1",
update: {
sessionUpdate: "agent_message_chunk",
content: { type: "text", text: "Fixed them." },
},
});
yield* Deferred.succeed(promptGate, { stopReason: "end_turn" });

const items = new Map<string, ProviderAdapter.ProviderAdapterV2Event>();
for (;;) {
const event = yield* Queue.take(events);
if (event.type === "turn.terminal") break;
if (event.type === "turn_item.updated") items.set(event.turnItem.id, event);
}
const shown = [...items.values()].flatMap((event) =>
event.type === "turn_item.updated" ? [event.turnItem] : [],
);
assert.deepEqual(
shown
.toSorted((left, right) => left.ordinal - right.ordinal)
.flatMap((item) =>
item.type === "assistant_message" || item.type === "reasoning"
? [`${item.type}: ${item.text}`]
: item.type === "system_notice"
? [`system_notice: ${item.message}`]
: [],
),
[
"assistant_message: Done.",
"system_notice: Fix the tests.",
"assistant_message: Fixed them.",
],
);
}).pipe(Effect.provide(layerTest), Effect.scoped),
);

it.effect("persists a bounded subset of streamed root and child tool updates", () =>
Effect.gen(function* () {
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
antigravityApprovalOptions,
antigravitySubagentOutput,
classifyAntigravitySubagentToolCall,
extractAntigravityStopHookNotice,
extractAntigravityUserInputQuestion,
makeAntigravityUserInputResponse,
normalizeAntigravityToolCall,
Expand Down Expand Up @@ -203,6 +204,7 @@ export function makeAntigravityAcpAdapterFlavor(
};
},
normalizeToolCall: normalizeAntigravityToolCall,
extractSystemNotice: extractAntigravityStopHookNotice,
extractSubagentUpdate: extractAntigravitySubagentUpdate,
supportsImagePrompts: true,
supportsCompaction: true,
Expand Down
Loading
Loading