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

@@ -16,6 +16,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,
@@ -190,11 +191,17 @@ export async function agentCommand(
const timeoutSecondsRaw =
opts.timeout !== undefined
? Number.parseInt(String(opts.timeout), 10)
: (agentCfg?.timeoutSeconds ?? 600);
if (Number.isNaN(timeoutSecondsRaw) || timeoutSecondsRaw <= 0) {
: undefined;
if (
timeoutSecondsRaw !== undefined &&
(Number.isNaN(timeoutSecondsRaw) || timeoutSecondsRaw <= 0)
) {
throw new Error("--timeout must be a positive integer (seconds)");
}
const timeoutMs = Math.max(timeoutSecondsRaw, 1) * 1000;
const timeoutMs = resolveAgentTimeoutMs({
cfg,
overrideSeconds: timeoutSecondsRaw,
});
const sessionResolution = resolveSession({
cfg,