Merge 46559bf7666c9a9b168fd4a5547d950761a2674c into 598f1826d8b2bc969aace2c6459824737667218c

This commit is contained in:
Miguel Miranda Dias 2026-03-21 04:21:39 +01:00 committed by GitHub
commit bb2bc9bd9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 27 deletions

View File

@ -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 () => {

View File

@ -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;