diff --git a/src/headless.ts b/src/headless.ts index 672ec9725..e27de3f91 100644 --- a/src/headless.ts +++ b/src/headless.ts @@ -753,11 +753,17 @@ async function runHeadlessOnce( resolveCompletion = resolve; }); - // Idle timeout — fallback completion detection + // Idle timeout — fallback completion detection. + // Multi-turn commands (auto, next, discuss, plan) involve LLM thinking + // pauses between tool calls that can exceed 15s. Use the longer + // new-milestone timeout for those too — without this, headless killed + // auto-mode after 2 tool calls when the LLM paused to reason about the + // next step (~35s total run, exit "complete" while task barely started). let idleTimer: ReturnType | null = null; - const effectiveIdleTimeout = isNewMilestone - ? NEW_MILESTONE_IDLE_TIMEOUT_MS - : IDLE_TIMEOUT_MS; + const effectiveIdleTimeout = + isNewMilestone || isMultiTurnCommand + ? NEW_MILESTONE_IDLE_TIMEOUT_MS + : IDLE_TIMEOUT_MS; function resetIdleTimer(): void { if (idleTimer) clearTimeout(idleTimer);