diff --git a/src/agents/bash-tools.exec.background-abort.test.ts b/src/agents/bash-tools.exec.background-abort.test.ts index 5c825177046..7eb487c554e 100644 --- a/src/agents/bash-tools.exec.background-abort.test.ts +++ b/src/agents/bash-tools.exec.background-abort.test.ts @@ -142,33 +142,16 @@ test("background exec still times out after tool signal abort", async () => { }); }); -test("background exec without explicit timeout ignores default timeout", async () => { +test("background exec without explicit timeout uses default timeout", async () => { const tool = createTestExecTool({ allowBackground: true, backgroundMs: 0, timeoutSec: BACKGROUND_TIMEOUT_SEC, }); - const result = await tool.execute("toolcall", { command: BACKGROUND_HOLD_CMD, background: true }); - expect(result.details.status).toBe("running"); - const sessionId = (result.details as { sessionId: string }).sessionId; - const waitMs = Math.max(ABORT_SETTLE_MS + 80, BACKGROUND_TIMEOUT_SEC * 1000 + 80); - - const startedAt = Date.now(); - await expect - .poll( - () => { - const running = getSession(sessionId); - const finished = getFinishedSession(sessionId); - return Date.now() - startedAt >= waitMs && !finished && running?.exited === false; - }, - { - timeout: waitMs + ABORT_WAIT_TIMEOUT_MS, - interval: POLL_INTERVAL_MS, - }, - ) - .toBe(true); - - cleanupRunningSession(sessionId); + await expectBackgroundSessionTimesOut({ + tool, + executeParams: { command: BACKGROUND_HOLD_CMD, background: true }, + }); }); test("yielded background exec still times out", async () => { diff --git a/src/agents/bash-tools.exec.ts b/src/agents/bash-tools.exec.ts index dcb50c0344c..8fa4d935e9a 100644 --- a/src/agents/bash-tools.exec.ts +++ b/src/agents/bash-tools.exec.ts @@ -491,11 +491,7 @@ export function createExecTool( } const explicitTimeoutSec = typeof params.timeout === "number" ? params.timeout : null; - const backgroundTimeoutBypass = - allowBackground && explicitTimeoutSec === null && (backgroundRequested || yieldRequested); - const effectiveTimeout = backgroundTimeoutBypass - ? null - : (explicitTimeoutSec ?? defaultTimeoutSec); + const effectiveTimeout = explicitTimeoutSec ?? defaultTimeoutSec; const getWarningText = () => (warnings.length ? `${warnings.join("\n")}\n\n` : ""); const usePty = params.pty === true && !sandbox;