Repository navigation
Description
Bug Description
In local Hermes Agent CLI sessions, once the conversation becomes long, API calls against a custom OpenAI-compatible provider start failing with a very high probability.
The user-facing message is:
Transient APITimeoutError on custom — rebuilt client, waiting 6s before one last primary attempt.
After that, Hermes frequently retries and then fails with repeated APITimeoutError entries. This seems to correlate strongly with long sessions / large context size. I found a related issue for APIConnectionError (#39524), but this report is specifically for APITimeoutError in long sessions.
Steps to Reproduce
- Use Hermes Agent locally in CLI interactive chat mode.
- Configure a custom OpenAI-compatible provider.
- Keep a session active until the conversation becomes long, around 300+ messages / ~230k-250k tokens in my logs.
- Continue chatting or trigger agent/tool turns.
- Hermes often prints:
Transient APITimeoutError on custom — rebuilt client, waiting 6s before one last primary attempt.
Expected Behavior
Hermes should continue the conversation successfully, or gracefully compress/reduce context and retry in a way that recovers from transient timeouts.
Actual Behavior
Hermes repeatedly times out on the custom provider after the session becomes long. Retrying usually does not recover.
Example from local logs:
2026-06-11 09:32:31,627 WARNING [20260610_180314_9e34c4] agent.conversation_loop: API call failed (attempt 1/3) error_type=APITimeoutError thread=bg-review:6146879488 provider=custom base_url=https://airoute.mycyjg.net/v1 model=gpt-5.5 summary=Request timed out.
2026-06-11 09:34:35,438 WARNING [20260610_180314_9e34c4] agent.conversation_loop: API call failed (attempt 2/3) error_type=APITimeoutError thread=bg-review:6146879488 provider=custom base_url=https://airoute.mycyjg.net/v1 model=gpt-5.5 summary=Request timed out.
2026-06-11 09:36:41,341 WARNING [20260610_180314_9e34c4] agent.conversation_loop: API call failed (attempt 3/3) error_type=APITimeoutError thread=bg-review:6146879488 provider=custom base_url=https://airoute.mycyjg.net/v1 model=gpt-5.5 summary=Request timed out.
2026-06-11 09:42:58,562 ERROR [20260610_180314_9e34c4] agent.conversation_loop: API call failed after 3 retries. Request timed out. | provider=custom model=gpt-5.5 msgs=322 tokens=~247,987
Another recent occurrence from the same machine/session:
2026-06-11 21:03:16,761 INFO [20260611_180158_18f012] agent.turn_context: conversation turn: session=20260611_180158_18f012 model=gpt-5.5 provider=custom platform=cli history=322 msg='Review the conversation above and update the skill library. Be ACTIVE — most ses...'
2026-06-11 21:03:26,648 INFO [20260611_180158_18f012] agent.conversation_loop: API call #1: model=gpt-5.5 provider=custom in=249867 out=127 total=249994 latency=9.9s cache=221696/249867 (89%)
2026-06-11 21:05:46,201 INFO [20260611_180158_18f012] agent.turn_context: conversation turn: session=20260611_180158_18f012 model=gpt-5.5 provider=custom platform=cli history=335 msg='不完整啊,你前面的结论是这样的: java domain.repository Repository BaseRepos...'
2026-06-11 21:10:01,736 WARNING [20260611_180158_18f012] agent.conversation_loop: API call failed (attempt 1/3) error_type=APITimeoutError thread=Thread-1124 (run_agent):6319648768 provider=custom base_url=https://airoute.mycyjg.net/v1 model=gpt-5.5 summary=Request timed out.
2026-06-11 21:12:05,850 WARNING [20260611_180158_18f012] agent.conversation_loop: API call failed (attempt 2/3) error_type=APITimeoutError thread=Thread-1124 (run_agent):6319648768 provider=custom base_url=https://airoute.mycyjg.net/v1 model=gpt-5.5 summary=Request timed out.
2026-06-11 21:14:12,146 WARNING [20260611_180158_18f012] agent.conversation_loop: API call failed (attempt 3/3) error_type=APITimeoutError thread=Thread-1124 (run_agent):6319648768 provider=custom base_url=https://airoute.mycyjg.net/v1 model=gpt-5.5 summary=Request timed out.
2026-06-11 21:16:19,269 WARNING [20260611_180158_18f012] agent.conversation_loop: API call failed (attempt 1/3) error_type=APITimeoutError thread=Thread-1124 (run_agent):6319648768 provider=custom base_url=https://airoute.mycyjg.net/v1 model=gpt-5.5 summary=Request timed out.
2026-06-11 21:18:22,865 WARNING [20260611_180158_18f012] agent.conversation_loop: API call failed (attempt 2/3) error_type=APITimeoutError thread=Thread-1124 (run_agent):6319648768 provider=custom base_url=https://airoute.mycyjg.net/v1 model=gpt-5.5 summary=Request timed out.
I also saw context compression immediately before one long-session continuation:
2026-06-11 18:00:07,893 INFO agent.conversation_compression: context compression started: session=20260611_152459_feee48 messages=310 tokens=~247,035 model=gpt-5.5 focus=None
2026-06-11 18:01:58,081 INFO [20260611_180158_18f012] agent.conversation_compression: context compression done: session=20260611_180158_18f012 messages=310->182 rough_tokens=~141,144 awaiting_real_usage=true
2026-06-11 18:01:58,297 INFO [20260611_180158_18f012] agent.turn_context: conversation turn: session=20260611_180158_18f012 model=gpt-5.5 provider=custom platform=cli history=182 msg='上下文超限了,请继续'
Affected Component
CLI (interactive chat), Agent Core (conversation loop, context compression, memory)
Messaging Platform (if gateway-related)
N/A (CLI only)
Debug Report
Output from hermes debug share --local, redacted to the relevant local dump and log excerpts:
Collecting debug report...
[hermes debug share: log content redacted at upload time. run with --no-redact to disable]
--- hermes dump ---
version: 0.16.0 (2026.6.5) [955fa400]
os: Darwin 25.5.0 arm64
python: 3.11.15
openai_sdk: 2.24.0
profile: default
hermes_home: ~/.hermes
model: glm-5.1
provider: auto
terminal: local
api_keys:
openrouter not set
openai not set
anthropic not set
anthropic_token not set
nous not set
google/gemini not set
gemini not set
glm/zai not set
zai not set
kimi not set
minimax not set
deepseek not set
dashscope not set
huggingface not set
nvidia not set
opencode_zen not set
opencode_go not set
kilocode not set
firecrawl not set
tavily not set
browserbase not set
fal not set
elevenlabs not set
github not set
features:
toolsets: hermes-cli
mcp_servers: 0
memory_provider: built-in
gateway: running (launchd)
platforms: weixin
cron_jobs: 0
skills: 76
config_overrides:
agent.max_turns: 150
display.streaming: True
--- end dump ---Operating System
macOS 26.5.1, Darwin 25.5.0, arm64
Python Version
Hermes runtime Python: 3.11.15
System python3 --version: 3.14.2
Hermes Version
Hermes Agent v0.16.0 (2026.6.5) · upstream 955fa40
OpenAI SDK: 2.24.0
Additional Logs / Traceback (optional)
Hermes version command output:
Hermes Agent v0.16.0 (2026.6.5) · upstream 955fa400
Project: /Users/huangxiao/.hermes/hermes-agent
Python: 3.11.15
OpenAI SDK: 2.24.0
Up to dateRoot Cause Analysis (optional)
I have not confirmed the root cause. From logs, the timeout rate increases significantly after long sessions around 300+ messages / ~230k-250k tokens. The visible retry path also mentions rebuilding the client before one last primary attempt.
Proposed Fix (optional)
No concrete patch yet. Possible areas to inspect:
- Timeout/retry strategy for custom OpenAI-compatible providers when request context is very large.
- Whether context compression should be triggered earlier or reduce more aggressively for custom providers.
- Whether rebuilding the client during stream retry preserves all custom provider options and timeout configuration.
Are you willing to submit a PR for this?
- I'd like to fix this myself and submit a PR
Activity
antifragileer commentedon Jun 11, 2026
👋 I'd like to take a crack at this.
Plan: Trace the retry/rebuild path in
agent/conversation_loop.py(the log filenameagent.conversation_loopand the messagerebuilt client, waiting 6s before one last primary attemptboth point there). My read: the retry path triggers on the firstAPITimeoutErrorfor a long session, fires the "rebuilt client" log, and then attempts exactly one more retry — which also times out and the whole turn fails. Expected behavior per the issue is graceful context reduction or a recovery-capable retry; current behavior is one-shot. I'll add a test-first regression that mocksAPITimeoutErrorto fire N times against a long-session config, then look at whether the retry path caps, logs "one last primary attempt" but then stops, and whether the loop's overall turn-success rate collapses.Test-first: Real
conversation_loopimport (per CONTRIBUTING.md E2E preference), with a stubbed HTTP client that returnsAPITimeoutErrordeterministically. Assertion is an invariant, not a frozen value.Estimate: Same-day if the code path is small, couple of days if there's an architectural question about how aggressive the retry/rebuild should be.
Heads up: if anyone else is already working on this, just comment below and I'll step back. I'll also re-check for duplicate PRs (timelineItems +
pr list --search "44285 in:body") immediately before submitting.— antifragileer (Hermes Agent contributor, June 2026)
fix(agent): compress long-session context on APITimeoutError recovery (…
DramaKing19 commentedon Jul 9, 2026
I experienced this issue with the NVIDIA BUILD provider. My log below.
🔁 Transient APITimeoutError on custom — rebuilt client, waiting 6s before one last primary attempt.
⚠️ No response from provider for 180s (model: google/gemma-4-31b-it, context: ~36,016 tokens). Reconnecting...
⚠️ API call failed (attempt 1/3): APITimeoutError
⚠️ No response from provider for 180s (model: google/gemma-4-31b-it, context: ~36,232 tokens). Reconnecting...
⚠️ API call failed (attempt 1/3): APITimeoutError
⚠️ No response from provider for 180s (model: google/gemma-4-31b-it, context: ~36,334 tokens). Reconnecting...
⚠️ API call failed (attempt 1/3): APITimeoutError
⚠️ No response from provider for 180s (model: google/gemma-4-31b-it, context: ~36,334 tokens). Reconnecting...
⚠️ API call failed (attempt 2/3): APITimeoutError
⚠️ No response from provider for 180s (model: google/gemma-4-31b-it, context: ~36,334 tokens). Reconnecting...
⚠️ API call failed (attempt 3/3): APITimeoutError
⚠️ No response from provider for 180s (model: google/gemma-4-31b-it, context: ~36,334 tokens). Reconnecting...
⚠️ API call failed (attempt 1/3): APITimeoutError
⚠️ No response from provider for 180s (model: google/gemma-4-31b-it, context: ~36,334 tokens). Reconnecting...
⚠️ API call failed (attempt 2/3): APITimeoutError
⚠️ API call failed (attempt 3/3): RuntimeError
🔌 Provider: custom Model: google/gemma-4-31b-it
🌐 Endpoint: https://integrate.api.nvidia.com/v1
📝 Error: Request timed out.
⏱️ Elapsed: 180.34s Context: 6 msgs, ~19,983 tokens
⏳ Retrying in 2.4s (attempt 1/3)...
🔌 Provider: custom Model: google/gemma-4-31b-it
🌐 Endpoint: https://integrate.api.nvidia.com/v1
📝 Error: Request timed out.
⏱️ Elapsed: 180.28s Context: 10 msgs, ~20,236 tokens
⏳ Retrying in 3.0s (attempt 1/3)...
🔌 Provider: custom Model: google/gemma-4-31b-it
🌐 Endpoint: https://integrate.api.nvidia.com/v1
📝 Error: Request timed out.
⏱️ Elapsed: 180.33s Context: 12 msgs, ~20,355 tokens
⏳ Retrying in 2.9s (attempt 1/3)...
🔌 Provider: custom Model: google/gemma-4-31b-it
🌐 Endpoint: https://integrate.api.nvidia.com/v1
📝 Error: Request timed out.
⏱️ Elapsed: 363.70s Context: 12 msgs, ~20,355 tokens
⏳ Retrying in 4.9s (attempt 2/3)...
🔌 Provider: custom Model: google/gemma-4-31b-it
🌐 Endpoint: https://integrate.api.nvidia.com/v1
📝 Error: Request timed out.
⏱️ Elapsed: 549.05s Context: 12 msgs, ~20,355 tokens
🔌 Provider: custom Model: google/gemma-4-31b-it
🌐 Endpoint: https://integrate.api.nvidia.com/v1
📝 Error: Request timed out.
⏱️ Elapsed: 735.43s Context: 12 msgs, ~20,355 tokens
⏳ Retrying in 2.3s (attempt 1/3)...
🔌 Provider: custom Model: google/gemma-4-31b-it
🌐 Endpoint: https://integrate.api.nvidia.com/v1
📝 Error: Request timed out.
⏱️ Elapsed: 918.18s Context: 12 msgs, ~20,355 tokens
⏳ Retrying in 4.3s (attempt 2/3)...
🔌 Provider: custom Model: google/gemma-4-31b-it
🌐 Endpoint: https://integrate.api.nvidia.com/v1
📝 Error: Provider has been unresponsive (no response received) for 5 consecutive stale attempts — aborting this call to avoid an indefinite stall. Switch models or start a new session, then retry.
⏱️ Elapsed: 922.60s Context: 12 msgs, ~20,355 tokens
❌ API failed after 3 retries — Provider has been unresponsive (no response received) for 5 consecutive stale attempts — aborting this call to avoid an indefinite stall. Switch models or start a new session, then retry.
💀 Final error: Provider has been unresponsive (no response received) for 5 consecutive stale attempts — aborting this call to avoid an indefinite stall. Switch models or start a new session, then retry.
antifragileer commentedon Jul 9, 2026
This happens on minimax too. I usually just open a new session and indicate the old session id and I am able to resume the conversation. Its not ideal but the workaround works pretty well for now
DramaKing19 commentedon Jul 9, 2026
I dug deeper. This is clearly ratelimiting, which isn't documented, but agentic workflows clearly blow through it quickly.
GottZ commentedon Jul 29, 2026
Summary
One PR addresses #44285 by attempting context compression during timeout recovery, but its helper-level mutation does not reach the local message payload used by the active retry loop. Its fixed 200-message threshold also misses the documented NVIDIA case with only 6–12 messages and roughly 20k tokens.
Related pull requests
best fix— (+223/-1) — partial fix, keep open for revision: fix(agent): compress long-session context on APITimeoutError recovery (#44285) #44489 adds guarded best-effort compression for timeout-class errors and focused helper tests, but the active retry continues using the existing localmessages/api_messages, so changingagent.messagesdoes not make the next wire request smaller. Consistent with the keep_open review on fix(agent): compress long-session context on APITimeoutError recovery (#44285) #44489, the recovery must propagate compressed messages through the conversation-loop restart path, use size-based eligibility that covers the shorter NVIDIA trace, and verify the reduced outbound request in an integration test.Suggested consolidation
Keep #44489 as the best-fix candidate, but do not merge it in its current form; revise it at the conversation-loop layer to restart with the compressed payload and add a wire-request integration test. There are no competing PRs to close as duplicates.
Complex graph
flowchart LR classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937 classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151 classDef best stroke-width:3px,stroke:#b45309 classDef target stroke-width:3px,stroke:#4338ca I44285(["issue #44285 (open)"]) P44489["PR #44489 (open)"] P44489 -->|best fix| I44285 class I44285 open class I44285 target class P44489 open class P44489 best click I44285 "https://github.com/NousResearch/hermes-agent/issues/44285" click P44489 "https://github.com/NousResearch/hermes-agent/pull/44489"Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).
Cross-PR triage: Reviewed 1 pull request and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 12 kB of PR diffs, 15 kB of issue/PR text, 12 kB of discussion (7 comments), 2 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
77techprogamer-sketch commentedon Sep 25, 2026
I have tried to uninstall-full and also clean re-install but also the issue is still not resolved. For the api i am using 9router. 9router is also re-installed. Please help urgently. Please resolve it quickly. Productivity is gone to ZERO. fix on top priority.