mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-25 17:18:11 +00:00
fix(agent): prevent agent hang after tool call completes
After a tool call completes, the conversation loop does to start the next API call. Between the last (from tool completion in tool_executor.py) and the next one (at the start of the next API call), there is a gap. If anything during this gap takes time — context compression, slow provider prefill, or other post-tool processing — the combined inactivity window can exceed the gateway's inactivity_timeout (default 120s). The gateway kills the session and the user sees 'agent never returns a final response', even though the tool call itself succeeded in 0.1-0.2s. Fix: call right before so the gateway sees a fresh timestamp immediately after tool results are posted, regardless of how long the follow-up API call takes. Fixes #69559
This commit is contained in:
parent
4582376cf3
commit
182c09b80b
1 changed files with 11 additions and 0 deletions
|
|
@ -5865,6 +5865,17 @@ def run_conversation(
|
|||
# Save session log incrementally (so progress is visible even if interrupted)
|
||||
agent._session_messages = messages
|
||||
|
||||
# Touch activity before continuing so the gateway's
|
||||
# inactivity monitor never sees a stale timestamp
|
||||
# between tool completion and the start of the next
|
||||
# API call. Without this, a tool-call result (which
|
||||
# takes ~0s to process) followed by slow post-tool
|
||||
# processing (compression, persist) and a slow
|
||||
# follow-up API call can exceed the gateway inactivity
|
||||
# timeout (HERMES_AGENT_TIMEOUT, default 1800s) and the
|
||||
# gateway kills the session before the next activity
|
||||
# touch fires (#69559, #69131).
|
||||
agent._touch_activity(f"tool results posted, continuing iteration #{api_call_count}")
|
||||
# Continue loop for next response
|
||||
continue
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue