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();