fix(auto): increase session timeout to 120s and treat timeout as recoverable pause (#3767)

NEW_SESSION_TIMEOUT_MS was 30s which fired before agent_end on slow-starting
tasks, causing spurious stopAuto hard stops. Increased to 120s and added a
dedicated timeout branch in runUnitPhase that calls pauseAuto (recoverable)
instead of stopAuto (destructive teardown).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jeremy 2026-04-08 18:15:31 -05:00
parent 477bf3c3fd
commit b619373f0d
3 changed files with 6 additions and 6 deletions

View file

@ -1303,8 +1303,8 @@ export async function runUnitPhase(
return { action: "break", reason: "provider-pause" };
}
// Session creation timeout (not a structural error): pause auto-mode
// and let the provider-error-resume timer handle recovery. This matches
// the provider-pause path — break out cleanly, don't hard-stop.
// and let the provider-error-resume timer handle recovery (#3767). This
// matches the provider-pause path — break out cleanly, don't hard-stop.
// Structural errors (TypeError, is not a function) are NOT transient
// and must hard-stop to avoid infinite retry loops.
if (
@ -1312,7 +1312,7 @@ export async function runUnitPhase(
unitResult.errorContext?.category === "timeout"
) {
ctx.ui.notify(
`Session creation timed out for ${unitType} ${unitId}. Will retry.`,
`Session creation timed out for ${unitType} ${unitId}. Pausing auto-mode (recoverable).`,
"warning",
);
debugLog("autoLoop", { phase: "session-timeout-pause", unitType, unitId });

View file

@ -67,7 +67,7 @@ export interface SidecarItem {
export const MAX_UNIT_DISPATCHES = 3;
export const STUB_RECOVERY_THRESHOLD = 2;
export const MAX_LIFETIME_DISPATCHES = 6;
export const NEW_SESSION_TIMEOUT_MS = 30_000;
export const NEW_SESSION_TIMEOUT_MS = 120_000;
// ─── AutoSession ─────────────────────────────────────────────────────────────

View file

@ -360,8 +360,8 @@ describe("session management", () => {
assert.equal(s.unitRecoveryCount.size, 0, "recovery counts cleared");
});
test("NEW_SESSION_TIMEOUT_MS is 30 seconds", () => {
assert.equal(NEW_SESSION_TIMEOUT_MS, 30_000, "session timeout should be 30s");
test("NEW_SESSION_TIMEOUT_MS is 120 seconds", () => {
assert.equal(NEW_SESSION_TIMEOUT_MS, 120_000, "session timeout should be 120s");
});
test("MAX_UNIT_DISPATCHES limits retries for a single unit", () => {