Skip to content

Stall guard: ten minutes by default, set in [daemon]; background commands may run a day - #621

Merged
lydakis merged 2 commits into
mainfrom
claude/project-thread-6vf5bw
Nov 1, 2026
Merged

lydakis merged 2 commits into
mainfrom
claude/project-thread-6vf5bw

Conversation

@lydakis

@lydakis lydakis commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Why

Claude at high effort on long context (170K to 230K tokens) can stream nothing but keepalive pings for most of a call. Calls ran up to 538 s. The 2-minute content-only stall bound failed 9 of 10 such runs as provider_stream_stalled, and each retry hit the same silence. With --stall-timeout 10m the same setup passed 22 of 22. A daemon that a client starts could not be given that flag, because [daemon] had no key for it.

What each provider says (read 2026-11-01)

Source What it documents
Anthropic streaming and errors docs Streams contain "any number of" ping events, with no stated interval or gap bound. Thinking arrives in a "chunky" pattern. The docs advise TCP keepalive for networks that drop idle connections. The SDKs time out after 10 minutes.
Bedrock Claude docs "The timeout period for inference calls … is 60 minutes", and they recommend raising the SDK read timeout to at least 3600 s. "Streamed events are not guaranteed to return at a constant rate." No stream idle limit is documented.
Codex config reference stream_idle_timeout_ms defaults to 300000 (5 min) per provider, with stream_max_retries defaulting to 5. Whether pings reset the timer is not documented.
OpenAI streaming and background docs No server stall bound is documented. The answer for long reasoning is background mode with a sequence_number cursor for resuming. The openai-python SDK times out after 10 minutes.
Claude Code network docs A byte watchdog fires when no bytes arrive, pings included: 180 s on the direct API, 300 s on Bedrock. An event watchdog fires after 5 min with no parsed event. Pings extend it for a limited time, so "a pings-only stream ends after about 12.5 minutes".

Two points follow. First, none of these sources is as strict as 2 minutes on content. Second, the closest precedent (Claude Code, which handles both Anthropic and Bedrock) does what this PR does: no bytes at all fails fast, and pings keep a stream alive for a bounded time of about 10 minutes.

What changes

  • STALL_TIMEOUT (src/provider.rs): 2 minutes → 10 minutes. Keepalives still don't renew it.
  • The 2-minute transport read bound is now named IDLE_READ. It still fails a connection that sends no bytes at all, pings included, so a dead connection is still found in 2 minutes.
  • reqwest's default TCP keepalive (15 s) stays on, which matches Anthropic's advice. Only a comment is added for it.
  • [daemon] stall_timeout = "15m" in config.toml now reaches --stall-timeout. It's a new DAEMON_DURATIONS table in client/src/config.rs, checked when the file is read: whole seconds, from 1 s to 24 h.
  • shell: a background command's timeout_ms may now go up to a day, the same as the wait cap. A background command holds no turn while it runs. Foreground commands stay capped at 600 s. Claude Code caps foreground commands at 10 minutes and background ones not at all, and Codex's exec sessions run until they exit. The daemon still bounds running processes with --max-processes and kills them at stop.
  • Updated docs: RUST_PROTOTYPE (limits table, the [daemon] key, the shell timeout_ms), CLI.md, and the --stall-timeout help.

Left alone: Responses streams count every non-delta event as progress, as before. No OpenAI stall has been reported, and changing that could end long reasoning that only keepalives cover.

Daemon fast and light

Nothing new runs on the runtime thread, and nothing new is kept per bot. The stream loop is unchanged apart from a constant. Validating the shell arguments picks a bound by background. There's no new store work.

Tests

  • cargo test --lib (200 passed), cargo test --bin agent (105 passed), agent-client lib (89 passed), daemon_knows_no_client.
  • New assertions: a [daemon] stall_timeout reaches its flag, and malformed values are refused by name. A background timeout_ms of 1 h is accepted, and one over a day is refused with the right message.

…ands may run a day

A Claude stream at high effort on long context can send nothing but pings
for most of a nine-minute call, so the two-minute content bound failed nine
of ten such runs. The bound is now ten minutes, about where Claude Code ends
a stream of pings alone; a connection that sends no bytes at all still
fails after two. [daemon] stall_timeout in config.toml sets it, so a daemon
a client starts can change it.

A background command holds no turn while it runs, so its timeout_ms may now
go to a day, as long as a wait on it may last; a foreground one stays at
600 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGCrC1SkXk5B5C9xa4M
@lydakis lydakis self-assigned this Nov 1, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T18:20:52.774673Z 88a8998 New commits
🔒 Security Review ✅ Completed 2026-11-01T18:00:41.243741Z d9a2867 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lydakis
lydakis merged commit 1594543 into main Nov 1, 2026
10 checks passed
lydakis pushed a commit that referenced this pull request Nov 1, 2026
The shell description keeps #621's day-long background cap and adds the
note's sentence after "collect its result later with wait.".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHSmyxToLa26Je2pfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants