From 7d34c1dc4c71bc8691facdf9cee8ef0b4b5942f9 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 5 Apr 2026 11:58:47 +0900 Subject: [PATCH] test(ci): cover non-waiting subagent completion --- .../subagent-registry-lifecycle.test.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/agents/subagent-registry-lifecycle.test.ts b/src/agents/subagent-registry-lifecycle.test.ts index d847ea9c672..a542ac36dd8 100644 --- a/src/agents/subagent-registry-lifecycle.test.ts +++ b/src/agents/subagent-registry-lifecycle.test.ts @@ -222,6 +222,44 @@ describe("subagent registry lifecycle hardening", () => { ); }); + it("does not wait for a completion reply when the run does not expect one", async () => { + const entry = createRunEntry({ + expectsCompletionMessage: false, + }); + const captureSubagentCompletionReply = vi.fn(async () => undefined); + + const controller = mod.createSubagentRegistryLifecycleController({ + runs: new Map([[entry.runId, entry]]), + resumedRuns: new Set(), + subagentAnnounceTimeoutMs: 1_000, + persist: vi.fn(), + clearPendingLifecycleError: vi.fn(), + countPendingDescendantRuns: () => 0, + suppressAnnounceForSteerRestart: () => false, + shouldEmitEndedHookForRun: () => false, + emitSubagentEndedHookForRun: vi.fn(async () => {}), + notifyContextEngineSubagentEnded: vi.fn(async () => {}), + resumeSubagentRun: vi.fn(), + captureSubagentCompletionReply, + runSubagentAnnounceFlow: vi.fn(async () => false), + warn: vi.fn(), + }); + + await expect( + controller.completeSubagentRun({ + runId: entry.runId, + endedAt: 4_000, + outcome: { status: "ok" }, + reason: SUBAGENT_ENDED_REASON_COMPLETE, + triggerCleanup: false, + }), + ).resolves.toBeUndefined(); + + expect(captureSubagentCompletionReply).toHaveBeenCalledWith(entry.childSessionKey, { + waitForReply: false, + }); + }); + it("skips browser cleanup when steer restart suppresses cleanup flow", async () => { const entry = createRunEntry({ expectsCompletionMessage: false,