File tree Expand file tree Collapse file tree
apps/server/src/orchestration-v2/Adapters Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9080,10 +9080,8 @@ describe("ClaudeAdapterV2 background wake turns", () => {
90809080 const pending = (yield* Queue.take(harness.runtimeRequestReceipts)).runtimeRequest;
90819081 assert.equal(pending.status, "pending");
90829082
9083+ // The turn can end right after the withdrawal, before the callback returns.
90839084 withdrawal.abort();
9084-
9085- assert.equal((yield* Fiber.join(permission))?.behavior, "deny");
9086- // Events arrive in order, so the turn's end follows anything the withdrawal emitted.
90879085 yield* Queue.offer(
90889086 harness.sdkMessages,
90899087 claudeSdkFrame({
@@ -9092,8 +9090,14 @@ describe("ClaudeAdapterV2 background wake turns", () => {
90929090 }),
90939091 );
90949092 yield* harness.awaitTerminal(1);
9093+ assert.equal((yield* Fiber.join(permission))?.behavior, "deny");
9094+ // The cancellation has to land before the turn's end finalizes the run.
9095+ const beforeTerminal = harness.events.slice(
9096+ 0,
9097+ harness.events.findIndex((event) => event.type === "turn.terminal"),
9098+ );
90959099 const statusOf = (type: "runtime_request.updated" | "node.updated" | "turn_item.updated") =>
9096- harness.events
9100+ beforeTerminal
90979101 .flatMap((event): Array<{ readonly type: string; readonly status: string }> =>
90989102 event.type === "runtime_request.updated" && event.runtimeRequest.id === pending.id
90999103 ? [{ type: event.type, status: event.runtimeRequest.status }]
You can’t perform that action at this time.
0 commit comments