Repository navigation
Description
Summary
When the stream idle watchdog (DEFAULT_STREAM_IDLE_TIMEOUT_MS = 120_000) aborts a mid-stream provider request, the whole run fails terminally with "Request timed out" — no provider-level retry, no run-level resume. Yet clicking Continue in Desktop immediately resumes the run and it proceeds to completion, which shows the failure was recoverable all along. On long deep-research turns with reasoning-heavy models (observed with DeepSeek V4 Pro), this kills multi-hour tasks twice a day.
Observed
Two runs on a local arm64 build of current main (0.1.8), swarm mode on, same failure shape (core_agent_runs.failureClass = "timeout", message "Request timed out"):
| run | step | time-to-first-token | aborted after | what the stream did |
|---|---|---|---|---|
| 1 | 21 | 299 ms | 129.8 s | opened, went quiet almost immediately |
| 2 | 15 | 333 ms | 1,009 s (~16.8 min) | streamed reasoning deltas for ~15 min, then 120 s of silence |
In both cases the Desktop turn banner shows 请求超时, the run is dead, and a manual Continue resumes it without loss (the resumed run completed its steps normally, one of them taking 117 s — 3 s under the same idle limit).
Why nothing recovers it (three separate gates)
-
The timeout is classified non-retryable. The watchdog throws a plain
Error("Model stream idle timeout after …ms")(stream-watchdog.ts→formatStreamWatchdogError).providerRetryMetadata()inprovider-error-classification.tsonly returnsretryable: truefor Network class or HTTP 408/409/429/5xx. A bare timeout Error has no status code and classifies asTimeout→retryable: false. Note the asymmetry: if the same hung connection were torn down by the OS instead (ECONNRESET → Network class), the existing per-step retry loop (MAX_PROVIDER_ATTEMPTS_PER_STEP = 10) would retry it. A connection that dies loudly is retried; one that hangs and gets reaped by our own watchdog is fatal. -
The observable-output gate blocks reasoning-only steps. Even if the failure were retryable,
attemptHasNoObservableOutput()inai-sdk-backend.tsrequiresstepThinking.length === 0. A reasoning model that thought for 15 minutes and never emitted text or a tool call fails this check, so the retry branch is unreachable for exactly the steps most likely to hit the idle timeout. -
The watchdog aborts the whole turn. Its
onTimeoutcallsturnAbortController.abort(...)(ai-sdk-backend.ts), so the failure is turn-terminal by construction — the retry sleep itself listens on that same signal.
Suggested direction
Either (or both):
- Treat a watchdog idle timeout as retryable when the aborted step produced only thinking — no text, no tool calls, no signature. Discarding partial reasoning and re-asking loses nothing durable, and is exactly what the manual Continue path already does successfully.
- Alternatively (or additionally), auto-resume once at the run level when a run fails with
failureClass: "timeout", mirroring the Continue action, with a cap to avoid loops.
Related prior art: #2119 fixed the watchdog falsely aborting during large tool-call argument streaming; #186 asks for timeout checkpoint/resume in Harbor. This issue is the interactive-run counterpart: the watchdog fires legitimately (the provider really did go silent), but the response to it is terminal instead of recoverable.
Activity
me2seeks commentedon Aug 8, 2026
I can take this. I’ll keep recovery inside the current provider step: the watchdog will cancel only the active provider request, and an idle timeout will get one bounded retry only when the attempt has produced no text, tool activity, or continuation signature. Partial thinking will remain visible and durable, while Stop will continue to own the turn-level abort. I’ll add deterministic coverage for reasoning-only recovery, effectful-output fail-closed behavior, and Stop during recovery.