Fails after 10 min with no bytes or 15 min with no real data; no total limit
Dead connection
30 s connect, TCP keepalive notices in about 60 s
Break after content
Codex keeps the partial reply as stop_reason="length". Other providers re-send the whole request on a transport failure and void the partial, see Re-sending a failed reply.
A reasoning stream must not carry a tight read timeout: a single timeout=120 caps the body read and fires over a buffering proxy, killing a healthy stream. Codex uses Timeout(connect=30, read=660, write=30, pool=30).
Budget
Reset by
Catches
SSE_IDLE_TIMEOUT_S 600
Any line, pings included
A dead connection. Codex's own client allows 5 min; 10 leaves room for a buffering proxy.
Stream idle bound 300
Parsed events only
A reply that stops while the connection stays open, pings included; retried. Every provider, see Idle bound
OPENPROGRAM_SSE_TOTAL_TIMEOUT_S 0
Nothing
Positive values opt into a deadline
Transport and recovery
Part
Behaviour
utils/http_transport/timeouts.py
The one timeout source, with context-scaling helpers
utils/http_transport/http_client.py
Keepalive, per OS. Force-IPv4 binds an IPv4 source, since httpx has no Happy Eyeballs. get_shared_async_client is loop-keyed, so Codex reuses TLS across turns. Proxy through httpx proxy=.
utils/http_transport/rate_limit.py
Parses x-ratelimit-*, anthropic-ratelimit-*; Codex warns when a bucket is low
retry_after_beyond_cap
One rule for the stream retry and Runtime.exec
Partial recovery, openai_codex.py
A transient break after content finalizes the turn; permanent failures still fail
openai-completions retry
After EventStart, before content: a retryable APIError, including xAI's status-less Internal error during token generation, reopens on the same model. Otherwise the outer handler records cooldown and re-raises.
gemini_cli
Same client and timeouts
Failover
utils/failures/failover.py and stream_with_failover try each fallback on a failover-worthy failure before content, forwarding events and suppressing the duplicate start.
model_fallback.mode
Tries
Crosses providers
off (default)
None; a 429 shows that error
–
same-provider
Up to two other enabled models of the provider, in config-row order, reusing the credential
no
list
model_fallback.models, provider/model ids in order
yes
Settings → Model services → Behavior, or openprogram config. OPENPROGRAM_FALLBACK_MODELS overrides it. A fallback reply records what was skipped in AssistantMessage.failover. Each switch also goes to the route_events table the routing overview reads.
30 min stream timeout on the undici dispatcher, reset by any byte. Forced HTTP/1.1 and Happy Eyeballs avoid h2 resets and broken IPv6. Two-tier retry. Key rotation with per-key transient retry. Failover categories as regex groups. Positive-only jitter with Retry-After; x-should-retry.
hermes-agent (Python, closest)
Keepalive socket injection and forced TCP close against CLOSE_WAIT. Decorrelated backoff seeded from time_ns. Stale timeout scaled by context, off for local providers. Separate first-byte and inter-event timeouts. Credential pool with cooldowns (401 5 min, 429/402 1 h, dead 24 h). Per-request OAuth hook. Partial reply with finish_reason=length.
opencode (TS)
No HTTP body timeout. WS: 15 s connect, 5 min idle, 55 min recycle, HTTP after 5 failures. Rate-limit headers into a structured object. Tagged-union errors.
pi-ai (TS, source of our Codex provider)
3 retries, 1 s base, 429/5xx and body patterns, no read timeout
claude-code (partial bundle)
HTTP behaviour is the Anthropic SDK's
Implementation status
Status
Items
Implemented
Classifier, retry and backoff, timeouts, shared client, keepalive, IPv4 switch, rate-limit parsing, opt-in failover, pre-content retry for Codex, OpenAI Responses and completions. The SDKs' own retries are off (max_retries=0); the credential layer retries and switches keys. Partial recovery: Codex only.
Credentials
Every request goes through auth/selection.py: a limited or refused credential is held and the next is tried. A sole credential cools like any other; the request waits up to 60 s for it with a notice, else fails saying when it is back.
Not built
Per-request OAuth hook: Codex already resolves and refreshes the bearer per call.