Repository navigation
Description
Summary
After upgrading to v0.13.0 (v2026.5.7), the APIConnectionError: Connection error. retry rate against chatgpt.com/backend-api/codex increased ~8x against the same workload. The retries persist even with PR #12953 (custom keepalive transport bypass) cherry-picked locally. Suspect commit 5533ad764 fix(auxiliary): enforce Codex Responses stream timeout is a contributing cause via a too-tight 120s default.
Environment
- Hermes Agent: v0.13.0 (v2026.5.7), commit
eeef486baseline + two local cherry-picks (aaa700c65= PR fix(codex): avoid custom keepalive transport on chatgpt backend #12953 keepalive bypass,4ce6c96e2= PR fix(auxiliary): resolve provider/model from live runtime, not stale config #19485 runtime TLS). - Provider:
openai-codex(ChatGPT Codex OAuth). - Models:
gpt-5.5main,gpt-5.4-miniauxiliary compression. - Backend:
chatgpt.com/backend-api/codex. - Platform: macOS 15.x arm64.
Empirical data
Logs counted across ~/.hermes/logs/agent.log, ~/.hermes/profiles/*/logs/agent.log, and ~/.hermes/kanban/logs/t_*.log:
- 2026-05-08 (pre-upgrade, full day): 21 retries.
- 2026-05-09 12:00–22:00 CDT (post-upgrade): 171+ retries.
- Same user, same workload class (Telegram-driven agent interactions plus an internal multi-agent workload), same network/IP.
Hourly post-upgrade peaks: 33–48 retries/hour. Pre-upgrade comparable: 0–2 retries/hour.
Symptom
Every retry signature in the post-upgrade window:
⚠️ API call failed (attempt 1/3): APIConnectionError
🔌 Provider: openai-codex Model: gpt-5.5
🌐 Endpoint: https://chatgpt.com/backend-api/codex
📝 Error: Connection error.
⏱️ Elapsed: 0.13–0.5s Context: varies
⏳ Retrying in 2-5s (attempt 1/3)...
Sub-second elapsed means TLS-handshake-time RST. ~95%+ of retries succeed within 1–3 attempts (no max-retries-exhausted events).
Hypothesis
Commit 5533ad764 enforces a hard total-elapsed timeout on the Codex Responses auxiliary stream. The default auxiliary.compression.timeout: 120s is too tight for compression workloads where 200K+ token sessions on gpt-5.4-mini routinely take 60–180s. Pre-commit, slow streams completed; post-commit, they timeout at 120s, raise TimeoutError, classify as retryable, and the outer agent loop fires a retry cycle that often surfaces as a transport-level APIConnectionError due to the forcible client.close() in _close_client_on_timeout.
Workaround
In ~/.hermes/config.yaml:
auxiliary:
compression:
timeout: 300 # was 120load_config() is mtime-cached so no restart needed. Reduces the compression-driven retry class. Connection-class retries (covered by #12952) are separate.
Related
- Bug: custom keepalive transport breaks chatgpt codex backend #12952 / PR fix(codex): avoid custom keepalive transport on chatgpt backend #12953 — custom keepalive transport breaks chatgpt codex backend (cherry-picked locally; reduces but does not eliminate).
- Compression fallback marker after incomplete chunked read loses useful context in long sessions #16670 / PR fix(compression): retry transient transport errors before fallback marker (#16670) #16737 — compression fallback marker after incomplete chunked read.
- PR fix(auxiliary): recover Codex stream drops #21761 — recover Codex stream drops (auxiliary path).
This issue is for the post-v0.13.0 amplification specifically, not the underlying transport instability that pre-existed.
Asks
- Confirm
5533ad764's 120s default is intended for production Codex-OAuth-on-ChatGPT-account workloads or should be tuned higher. - Consider exposing a per-call override or auto-scaling the deadline based on observed stream throughput.
- Either way, document the workaround for users hitting the regression.
Activity
QuarkAssistant commentedon May 21, 2026
Follow-up: v0.14.0 (v2026.5.16) upgrade — pattern recurs, but not in the auxiliary-timeout class
Filing as the original reporter. 11 days of clean operation followed by a same-day spike post-v0.14.0 upgrade.
Updated retry-count timeline
Same workload class, same network, same provider config (
openai-codex/ ChatGPT Codex OAuth /gpt-5.5):auxiliary.compression.timeoutworkaround applied)PR #12953's local cherry-pick (
_is_chatgpt_codex_backendhelper +_create_openai_clientkeepalive bypass) was sufficient to eliminate the v0.13.0 retry baseline entirely between 5/10 and 5/17 — confirming the original transport diagnosis was correct for that period. The 11-day zero-error window also held WITHOUT theauxiliary.compression.timeout: 300workaround, suggesting the original 8x amplification is not load-bearing for our specific workload (relatively small contexts, ChatGPT Codex OAuth lane).Today's spike — direct code inspection rules out a new bypass
Read-only audit of the v2026.5.16 source tree (PR #12953 cherry-pick rebased onto the v0.14.0 base):
_is_chatgpt_codex_backenddefined atrun_agent.py:6754(PR fix(codex): avoid custom keepalive transport on chatgpt backend #12953 helper, intact)._create_openai_clientkeepalive-transport injection atrun_agent.py:6864is properly gated by the helper (if "http_client" not in client_kwargs and not self._is_chatgpt_codex_backend(self.provider, client_kwargs.get("base_url")):). Verified the only other_build_keepalive_http_client()call site atrun_agent.py:6824is inside theis_native_gemini_base_url(base_url)branch — Gemini-native path, never reached for chatgpt-codex.agent/auxiliary_client.pyhas separateOpenAI(...)constructors but they emit different log strings (Codex auxiliary Responses API call failed) and are not thecodex_stream_requestreason-string we see on today's failures.agent/codex_responses_adapter.pyandagent/transports/codex.pyconsume rather than construct clients.__editable___hermes_agent_0_14_0_finder.py) confirms the gateway loads from the tree on disk — no shadow snapshot.So today's failures are NOT due to a new v0.14.0 client construction site that bypasses PR #12953's bypass.
Failure signature
Identical to the original #12952/#12953 transport-shape, ~240ms client lifetime then clean close → immediate
APIConnectionError:tcp_force_closed=0means clean shutdown — not the socket-RST class the keepalive bypass fixed. The 120-240ms create→close→error pattern with provider=openai-codex / chatgpt.com base_url suggests TLS-handshake-then-error on the upstream side (ChatGPT-codex backend rejecting or RSTing after handshake completes), not local transport misconfiguration.Concurrent factor: live OpenAI status incident
status.openai.comshows an active incident "Elevated error rates on ChatGPT paid plans" — ongoing for ~7h at time of writing, overlapping the entire 12:00-16:00 CDT spike window. This is a plausible direct cause for the surge, layered on top of:5533ad764strict stream-timeout enforcement classifying timeouts as APIConnectionError (raises visibility of stalls that pre-upgrade may have been silent).Refined ask
5533ad764is converting previously-silent stream stalls intoAPIConnectionError-classified retries (rather than just raisingTimeoutError), that may be a separate observability issue — consider distinguishing "stream timeout, retryable" from "transport error, retryable" in the retry-loop classifier so users can filter noise during upstream incidents._close_client_on_timeoutsuch that a force-close races with the OpenAI SDK's response-stream parse, producing the 240ms-then-APIConnectionError shape we're seeing.Will continue measuring through the OpenAI incident resolution and re-report if the pattern persists past that.
miguelmanlyx commentedon May 21, 2026
Probably OpenAI timeout conditions. A quick
npx ai-doctorrun can flag missing timeout guards and unprotected requests.teknium1 commentedon Jul 13, 2026
Thanks for the detailed measurements and follow-up separating the timeout and transport classes.
Automated hermes-sweeper review found this specific compression-timeout regression is implemented on current main:
370a489fb4adb7268f6510439e25e8213bddb624(fix(auxiliary): floor compression timeout so reasoning models don't fall back to marker, shipped inv2026.7.7) applies a bounded 300-second floor to config-derivedcompressiontimeouts.agent/auxiliary_client.py:6065-6068limits that behavior to compression and preserves explicit per-call deadlines.tests/agent/test_auxiliary_compression_timeout_floor.py:77-189covers the former 120-second path plus sync/async, explicit-override, and scope boundaries.agent/auxiliary_client.py:1137-1140reports an enforced stream deadline asTimeoutError, whileagent/auxiliary_client.py:6575-6581avoids repeating a full-budget same-provider compression timeout.The later upstream/transport retry observations are distinct from the 120-second compression deadline addressed here.