From 1c9dc8751fd517e5662181f76f89a0af6c5b6fd4 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Sat, 7 Nov 2026 07:04:16 +0000 Subject: [PATCH] test(claude): reproduce stopped background child restored as running --- .../claude/agent.sub-agent-replay.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/server/src/server/agent/providers/claude/agent.sub-agent-replay.test.ts b/packages/server/src/server/agent/providers/claude/agent.sub-agent-replay.test.ts index 91007aa7ce..d943b210f6 100644 --- a/packages/server/src/server/agent/providers/claude/agent.sub-agent-replay.test.ts +++ b/packages/server/src/server/agent/providers/claude/agent.sub-agent-replay.test.ts @@ -648,6 +648,23 @@ describe("ClaudeAgentSession persisted subagent replay", () => { ); } + test("cancels a background child from a task-id-only stopped notification on reopen", async () => { + const text = `\n${AGENT_ID}\nstopped\nBackground agent didn't finish before the previous session ended\n`; + writeSession({ + parentLines: [ + ...backgroundLaunch(), + JSON.stringify({ type: "queue-operation", operation: "enqueue", content: text }), + JSON.stringify({ type: "user", message: { role: "user", content: text } }), + ], + meta: JSON.stringify({ toolUseId: TOOL_USE_ID }), + sidechainLines: [sidechainEntry({ stopReason: "tool_use" })], + }); + expect(upserts(await replayDescriptors()).at(-1)).toMatchObject({ + id: TOOL_USE_ID, + status: "canceled", + }); + }); + test("prefers a stopped notification over the child's end_turn", async () => { writeSession({ parentLines: [...backgroundLaunch(), taskNotification("stopped")],