refactor: centralize agent timeout defaults

This commit is contained in:
Peter Steinberger
2026-01-06 02:48:44 +00:00
parent d83ca74c18
commit 20a361a3cf
9 changed files with 90 additions and 27 deletions

View File

@@ -13,6 +13,7 @@ import {
} from "../agents/model-selection.js";
import { runEmbeddedPiAgent } from "../agents/pi-embedded.js";
import { buildWorkspaceSkillSnapshot } from "../agents/skills.js";
import { resolveAgentTimeoutMs } from "../agents/timeout.js";
import {
DEFAULT_AGENT_WORKSPACE_DIR,
ensureAgentWorkspace,
@@ -234,12 +235,13 @@ export async function runCronIsolatedAgentTurn(params: {
});
}
const timeoutSecondsRaw =
params.job.payload.kind === "agentTurn" && params.job.payload.timeoutSeconds
? params.job.payload.timeoutSeconds
: (agentCfg?.timeoutSeconds ?? 600);
const timeoutSeconds = Math.max(Math.floor(timeoutSecondsRaw), 1);
const timeoutMs = timeoutSeconds * 1000;
const timeoutMs = resolveAgentTimeoutMs({
cfg: params.cfg,
overrideSeconds:
params.job.payload.kind === "agentTurn"
? params.job.payload.timeoutSeconds
: undefined,
});
const delivery =
params.job.payload.kind === "agentTurn" &&