ワンクリックで
stream-retry-tuning
Tune HERMES_STREAM_RETRIES for mid-stream reconnect resilience.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Tune HERMES_STREAM_RETRIES for mid-stream reconnect resilience.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Guides Cloudflare One Zero Trust and SASE work across Access, Gateway, WARP, Tunnel, Cloudflare WAN, DLP, CASB, device posture, and identity. Use when designing, configuring, troubleshooting, or reviewing Cloudflare One deployments. Retrieval-first: use current Cloudflare docs/API schemas instead of embedded product docs.
Use when scheduling recurring polls, read-only monitors, or background jobs that must survive shell session boundaries.
Discover, register, and maintain Hermes skills from non-default paths (plugin directories, external repos, shared vaults). Use when skills are missing from `skills_list()`, when the user mentions plugin skills, when symlinking skills, or when reconciling duplicate/overlapping skills between the default tree and external sources.
Operate the Antigravity CLI (agy): plugins, auth, sandbox.
Manage parallel Hermes sessions in Telegram topics.
Run a startup checklist via a gateway:startup hook on every boot.
| name | stream-retry-tuning |
| description | Tune HERMES_STREAM_RETRIES for mid-stream reconnect resilience. |
| version | 0.1.0 |
| author | Hermes |
| metadata | {"hermes":{"tags":["Hermes","Streaming","Retry","Network","Reliability"]}} |
Control how many times Hermes silently reconnects when an LLM streaming response drops mid-flight due to a transient network error. HERMES_STREAM_RETRIES is an environment variable (read once per API call via env_int) that governs mid-stream reconnect attempts independently of the app-level agent.api_max_retries config key. The two operate at different layers: stream retries handle connection drops during streaming; api_max_retries handles entire API call failures.
~/.hermes/.env (or profile-specific ~/.hermes/profiles/<name>/.env).Set the environment variable, then restart the session. Invoke through the terminal tool:
# Add to .env
echo 'HERMES_STREAM_RETRIES=5' >> ~/.hermes/.env
# Or export for a single CLI session
HERMES_STREAM_RETRIES=5 hermes
Then start a new session (/reset or relaunch). The value is read inside _call() at the start of each streaming API call via env_int("HERMES_STREAM_RETRIES", 2).
| Env var | Code default | Docs default | Total attempts | Scope |
|---|---|---|---|---|
HERMES_STREAM_RETRIES | 2 | 3 | value + 1 | Per streaming API call |
HERMES_STREAM_RETRIES=0 # no retry, single attempt
HERMES_STREAM_RETRIES=1 # 1 retry → 2 total attempts
HERMES_STREAM_RETRIES=2 # code default → 3 total attempts
HERMES_STREAM_RETRIES=5 # high tolerance → 6 total attempts
Check current value — invoke through the terminal tool:
grep HERMES_STREAM_RETRIES ~/.hermes/.env 2>/dev/null || echo "not set (code default: 2)"
Set the desired value in .env:
echo 'HERMES_STREAM_RETRIES=5' >> ~/.hermes/.env
Restart the session — the env var is read at call time, but .env is loaded at process start:
hermes./restart or hermes gateway restart.Verify — in a new session, confirm the env var loaded:
hermes config env-path # confirm .env location
grep HERMES_STREAM_RETRIES "$(hermes config env-path)"
The retry loop (for _stream_attempt in range(_max_stream_retries + 1)) catches these transient errors:
ReadTimeout, ConnectTimeout, PoolTimeoutConnectError, RemoteProtocolError, ConnectionErroropenai.APIError with no status_code whose message contains phrases like "connection lost", "network error", "broken pipe", "upstream connect error", "peer closed", "connection reset", "connection terminated"agent._is_provider_stream_parse_error(e)No tokens delivered yet (deltas_were_sent["yes"] == False): silent retry with fresh connection. The stale httpx client is closed and rebuilt before each retry. A _emit_stream_drop diagnostic is logged.
Tokens already delivered + tool call in-flight: silent retry ONLY if the error is transient AND retries remain. The user sees a ⚠ Connection dropped mid tool-call; reconnecting… marker, stream delivery tracking is reset, and the preamble is re-streamed. This prevents losing a tool call to a network blip.
Tokens delivered, no tool call in-flight: NO retry. The partial text is kept as the response stub (retrying would duplicate visible text). The error is logged and the call returns.
_request_cancelled) exit without retry — these are self-inflicted from /stop.env_int("HERMES_STREAM_RETRIES", 2) — 2 retries, 3 total attempts. Both are correct from their perspective; don't be confused by the mismatch.agent.api_max_retries (config-level), this is an env var read via os.getenv/env_int. Set it in .env, not config.yaml.max_retries=2). HERMES_STREAM_RETRIES wraps the streaming call including SDK retries.agent.api_max_retries. That config key retries the entire API call (including non-streaming). HERMES_STREAM_RETRIES retries only mid-stream connection drops during a single streaming response./stop. Each retry on a slow provider (e.g. Ollama Cloud) can block for the full stream-read timeout (120s+). Setting HERMES_STREAM_RETRIES=5 means /stop could wait up to 6×120s = 12 minutes before the interrupt takes effect. The code checks _interrupt_requested before each retry attempt, but the current attempt must still time out.env_int catches ValueError/TypeError and returns the default (2). A typo like HERMES_STREAM_RETRIES=high silently means 2 retries, not an error.HERMES_STREAM_RETRIES=0 disables all stream retry. Used in tests to force immediate propagation. The initial attempt still runs, but no retries on failure.grep HERMES_STREAM_RETRIES ~/.hermes/.env
Should show your configured value. For runtime confirmation, check logs after a stream drop — the _emit_stream_drop diagnostic logs the attempt number and max attempts (e.g. "attempt 2/3").