Gemini timeout recovery
Gemini timeout recovery
The recovery below applies to standalone bridge calls with a soft timeout. Unified MCP calls use an absolute deadline (retries share it), abort the process group at that deadline, and grant no additional drain period. Host caps also disable drain.
timeout is a soft deadline (default 300000ms; Gemini 3 deep prompts run
200-260s). agy -p streams its answer to stdout incrementally, so the bridge
recovers by draining that stream rather than scraping disk. When the soft timeout
fires, the bridge does not fail immediately: it keeps agy alive and keeps
buffering its streamed stdout for up to recovery-grace ms (default 120000, range
0..600000). If agy completes cleanly within the grace budget (exit 0, no Error:
sentinel on stdout), the buffered output is returned as a normal success with a
top-level "recovered": true flag and a stderr log line; content is the full
answer so response parsers keep working. If agy is still running when the grace
budget is exhausted, the call fails with errorKind: "timeout" (still
retryable).
"recovery-grace": 0disables the drain (immediate legacy timeout).GEMINI_DISABLE_TIMEOUT_RECOVERY=1(env) forces full legacy behavior.- The call resolves within
timeout + recovery-grace. Theagychild process is then killedSIGTERM, with aSIGKILLabout 1s later; that kill is async cleanup and does not delay the response.