Skip to content

Commit 68ed763

Browse files
committed
test(server): preserve background report race coverage after task completion
1 parent 682ba88 commit 68ed763

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10109,7 +10109,9 @@ describe("AcpAdapterV2", () => {
1010910109
deferFinalizeForBackgroundWork: true,
1011010110
enablePostSettleContinuation: true,
1011110111
extractBackgroundTaskId: (toolCall) =>
10112-
toolCall.toolCallId === "tool-call-monitor-1" ? "task-monitor-1" : undefined,
10112+
toolCall.toolCallId.startsWith("tool-call-monitor-")
10113+
? toolCall.toolCallId.replace("tool-call-", "task-")
10114+
: undefined,
1011310115
extractBackgroundToolMutation: (text) =>
1011410116
text.includes('Monitor "task-monitor-1" ended')
1011510117
? [{ taskId: "task-monitor-1", status: "completed", appendOutput: "" }]
@@ -10205,6 +10207,16 @@ describe("AcpAdapterV2", () => {
1020510207
taskId: "task-monitor-1",
1020610208
status: "running",
1020710209
});
10210+
yield* sessionUpdateHandler!({
10211+
sessionId: "mock-session-1",
10212+
update: {
10213+
sessionUpdate: "tool_call",
10214+
toolCallId: "tool-call-monitor-2",
10215+
title: "Monitor: hold while the first report arrives",
10216+
kind: "execute",
10217+
status: "in_progress",
10218+
},
10219+
});
1020810220
// Completion ext PRE-settle: arms midTurnUnreportedCompletedTaskIds.
1020910221
yield* applyMutation({
1021010222
sessionId: "mock-session-1",
@@ -10217,8 +10229,8 @@ describe("AcpAdapterV2", () => {
1021710229
"pre-settle unhandled completion must not offer while the turn is active",
1021810230
);
1021910231

10220-
// Settle without reporting. Tool stays in_progress so deferred finalize
10221-
// holds the turn open for the injected report.
10232+
// The completed monitor no longer blocks settlement. The other monitor
10233+
// is still running, so the injected report races into the held turn.
1022210234
yield* Deferred.succeed(promptGate, { stopReason: "end_turn" });
1022310235
yield* Effect.yieldNow;
1022410236
yield* Effect.yieldNow;
@@ -10280,7 +10292,15 @@ describe("AcpAdapterV2", () => {
1028010292
}
1028110293
assert.isTrue(reportSeen, "injected report must project into the held turn");
1028210294

10283-
// Hydration safety (60s) force-completes the monitor tool, then the 3s
10295+
yield* sessionUpdateHandler!({
10296+
sessionId: "mock-session-1",
10297+
update: {
10298+
sessionUpdate: "tool_call_update",
10299+
toolCallId: "tool-call-monitor-2",
10300+
status: "completed",
10301+
},
10302+
});
10303+
// Hydration safety (60s) clears the text-notice hold, then the 3s
1028410304
// quiet window finalizes. No TaskOutput path: that would also clear
1028510305
// midTurn and hide the agent_message_chunk consumption site under test.
1028610306
yield* TestClock.adjust("60 seconds");

0 commit comments

Comments
 (0)