The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: local Responses TTFB grace invariants + timeout docs (#92302)
teknium14a4e0ff45192
diff --git a/tests/agent/test_codex_ttfb_watchdog.py b/tests/agent/test_codex_ttfb_watchdog.pyindex 62b2c50ae73..2382c11ce2d 100644--- a/tests/agent/test_codex_ttfb_watchdog.py+++ b/tests/agent/test_codex_ttfb_watchdog.py@@ -102,6 +102,32 @@ def _install_codex_event_stream(agent, monkeypatch, event_factory, closes):)+def test_local_endpoint_ttfb_default_uses_local_stale_ceiling(tmp_path, monkeypatch):+ """#92302: a local Responses endpoint gets the local stale ceiling as its implicit+ no-event TTFB cutoff (the chat-completions siblings already grant local servers that+ prefill grace); hosted endpoints keep the 120s default."""+ from agent import chat_completion_helpers as h++ monkeypatch.setenv("HERMES_LOCAL_STREAM_STALE_TIMEOUT", "600")+ local = _make_codex_agent(tmp_path, monkeypatch, provider="custom", base_url="http://127.0.0.1:11434/v1")+ hosted = _make_codex_agent(tmp_path, monkeypatch, provider="custom", base_url="https://api.example.com/v1")+ kwargs = {"model": "qwen3-27b", "input": "hi"}++ assert h._resolve_nonstream_watchdogs(local, kwargs).ttfb_timeout == 600.0+ assert h._resolve_nonstream_watchdogs(hosted, kwargs).ttfb_timeout == 120.0+++def test_local_endpoint_ttfb_explicit_env_still_wins(tmp_path, monkeypatch):+ """An operator-set HERMES_CODEX_TTFB_TIMEOUT_SECONDS is honoured verbatim on local endpoints."""+ from agent import chat_completion_helpers as h++ monkeypatch.setenv("HERMES_LOCAL_STREAM_STALE_TIMEOUT", "600")+ local = _make_codex_agent(tmp_path, monkeypatch, provider="custom", base_url="http://127.0.0.1:11434/v1")+ monkeypatch.setenv("HERMES_CODEX_TTFB_TIMEOUT_SECONDS", "45")++ assert h._resolve_nonstream_watchdogs(local, {"model": "qwen3-27b", "input": "hi"}).ttfb_timeout == 45.0++def test_ttfb_includes_silent_hang_hint_for_gpt_5_5(tmp_path, monkeypatch):"""The no-first-event watchdog should surface the same actionable hint as thestale-call timeout path when the model matches the silent-hang heuristic."""diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.mdindex 4c8e471466a..e5d0734b223 100644--- a/website/docs/user-guide/configuration.md+++ b/website/docs/user-guide/configuration.md@@ -1249,12 +1249,15 @@ Hermes has separate timeout layers for streaming, plus a stale detector for non-| Socket read timeout | 120s | Auto-raised to 1800s | `HERMES_STREAM_READ_TIMEOUT` || Stale stream detection | 180s | Raised to a 900s ceiling (`agent.local_stream_stale_timeout`) | `HERMES_STREAM_STALE_TIMEOUT` || Stale non-stream detection | 90s | Auto-disabled when left implicit | `providers.<id>.stale_timeout_seconds` or `HERMES_API_CALL_STALE_TIMEOUT` |+| Responses first-event watchdog | 120s | Raised to the 900s ceiling (`agent.local_stream_stale_timeout`) | `HERMES_CODEX_TTFB_TIMEOUT_SECONDS` || API call (non-streaming) | 1800s | Unchanged | `providers.<id>.request_timeout_seconds` / `timeout_seconds` or `HERMES_API_TIMEOUT` |The **socket read timeout** controls how long httpx waits for the next chunk of data from the provider. Local LLMs can take minutes for prefill on large contexts before producing the first token, so Hermes raises this to 30 minutes when it detects a local endpoint. If you explicitly set `HERMES_STREAM_READ_TIMEOUT`, that value is always used regardless of endpoint detection.The **stale stream detection** kills connections that receive SSE keep-alive pings but no actual content. For local providers (which don't send keep-alive pings during prefill) the default is raised to a finite 900-second ceiling instead of the 180s base — configurable via `agent.local_stream_stale_timeout` or the `HERMES_LOCAL_STREAM_STALE_TIMEOUT` env var.+The **Responses first-event watchdog** (Codex / `codex_responses` transport, including custom providers declared with the Responses transport) aborts and reconnects a request that accepts the connection but emits no stream event within 120 seconds. A local server prefilling a large context legitimately stays silent longer than that, so on local endpoints the implicit default is raised to the same ceiling as the stale stream detector (`agent.local_stream_stale_timeout` / `HERMES_LOCAL_STREAM_STALE_TIMEOUT`, 900s). An explicit `HERMES_CODEX_TTFB_TIMEOUT_SECONDS` is always used as-is (`0` disables the watchdog).+The **stale non-stream detection** kills non-streaming calls that produce no response for too long. By default Hermes disables this on local endpoints to avoid false positives during long prefills. If you explicitly set `providers.<id>.stale_timeout_seconds`, `providers.<id>.models.<model>.stale_timeout_seconds`, or `HERMES_API_CALL_STALE_TIMEOUT`, that explicit value is honored even on local endpoints.This budget bounds every non-streaming call. A provider that accepts a request and then goes silent — connection held open, no bytes, no error — is aborted at the stale timeout and retried, rather than hanging until the much longer socket read timeout (or, for an unattended cron run, until something external kills the process).