From 906c32da127a5e15f66f38a15e883570cf291da7 Mon Sep 17 00:00:00 2001 From: Vignesh Natarajan Date: Sat, 14 Feb 2026 18:18:03 -0800 Subject: [PATCH] chore (exec): add PTY background abort regression test --- ...sh-tools.exec.background-abort.e2e.test.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/agents/bash-tools.exec.background-abort.e2e.test.ts b/src/agents/bash-tools.exec.background-abort.e2e.test.ts index 949999de243..89f6c261474 100644 --- a/src/agents/bash-tools.exec.background-abort.e2e.test.ts +++ b/src/agents/bash-tools.exec.background-abort.e2e.test.ts @@ -43,6 +43,37 @@ test("background exec is not killed when tool signal aborts", async () => { } }); +test("pty background exec is not killed when tool signal aborts", async () => { + const tool = createExecTool({ allowBackground: true, backgroundMs: 0 }); + const abortController = new AbortController(); + + const result = await tool.execute( + "toolcall", + { command: 'node -e "setTimeout(() => {}, 5000)"', background: true, pty: true }, + abortController.signal, + ); + + expect(result.details.status).toBe("running"); + const sessionId = (result.details as { sessionId: string }).sessionId; + + abortController.abort(); + + await sleep(150); + + const running = getSession(sessionId); + const finished = getFinishedSession(sessionId); + + try { + expect(finished).toBeUndefined(); + expect(running?.exited).toBe(false); + } finally { + const pid = running?.pid; + if (pid) { + killProcessTree(pid); + } + } +}); + test("background exec still times out after tool signal abort", async () => { const tool = createExecTool({ allowBackground: true, backgroundMs: 0 }); const abortController = new AbortController();