fix: stale agent timeout, uv venv detection, empty response after tools (#9051, #8620, #9400) - #10065
Merged
Conversation
teknium1
force-pushed
the
hermes/hermes-a8920bf7
branch
from
April 15, 2026 04:24
b16085a to
1c56247
Compare
…ls (#9051, #8620, #9400) Three independent fixes: 1. Reset activity timestamp on cached agent reuse (#9051) When the gateway reuses a cached AIAgent for a new turn, the _last_activity_ts from the previous turn (possibly hours ago) carried over. The inactivity timeout handler immediately saw the agent as idle for hours and killed it. Fix: reset _last_activity_ts, _last_activity_desc, and _api_call_count when retrieving an agent from the cache. 2. Detect uv-managed virtual environments (#8620 sub-issue 1) The systemd unit generator fell back to sys.executable (uv's standalone Python) when running under 'uv run', because sys.prefix == sys.base_prefix (uv doesn't set up traditional venv activation). The generated ExecStart pointed to a Python binary without site-packages, crashing the service on startup. Fix: check VIRTUAL_ENV env var before falling back to sys.executable. uv sets VIRTUAL_ENV even when sys.prefix doesn't reflect the venv. 3. Nudge model to continue after empty post-tool response (#9400) Weaker models (GLM-5, mimo-v2-pro) sometimes return empty responses after tool calls instead of continuing to the next step. The agent silently abandoned the remaining work with '(empty)' or used prior-turn fallback text. Fix: when the model returns empty after tool calls AND there's no prior-turn content to fall back on, inject a one-time user nudge message telling the model to process the tool results and continue. The flag resets after each successful tool round so it can fire again on later rounds. Test plan: 97 gateway + CLI tests pass, 9 venv detection tests pass
teknium1
force-pushed
the
hermes/hermes-a8920bf7
branch
from
April 15, 2026 04:32
1c56247 to
f23edda
Compare
This was referenced Apr 15, 2026
This was referenced Jun 24, 2026
g4bwy
added a commit
to g4bwy/maki
that referenced
this pull request
Jul 1, 2026
Weaker models sometimes return an empty response after executing tool calls (no text, no tool uses, just end_turn), silently abandoning incomplete multi-step tasks. When this happens, inject a synthetic user message asking the model to process the tool results and continue. Guarded by a per-tool-round flag and the global turn limit to prevent infinite loops. - Add AgentEvent::Nudge variant and UI handling - Add History::has_recent_tool_results() helper - Make Message::first_text_content() public - Add nudge detection in turn() with synthetic message injection Ported from: NousResearch/hermes-agent#10065 Addresses issue tontinton#299 (among others)
tontinton
pushed a commit
to g4bwy/maki
that referenced
this pull request
Jul 3, 2026
Weaker models sometimes return an empty response after executing tool calls (no text, no tool uses, just end_turn), silently abandoning incomplete multi-step tasks. When this happens, inject a synthetic user message asking the model to process the tool results and continue. Guarded by a per-tool-round flag and the global turn limit to prevent infinite loops. - Add AgentEvent::Nudge variant and UI handling - Add History::has_recent_tool_results() helper - Make Message::first_text_content() public - Add nudge detection in turn() with synthetic message injection Ported from: NousResearch/hermes-agent#10065 Addresses issue tontinton#299 (among others)
tontinton
pushed a commit
to tontinton/maki
that referenced
this pull request
Jul 3, 2026
Weaker models sometimes return an empty response after executing tool calls (no text, no tool uses, just end_turn), silently abandoning incomplete multi-step tasks. When this happens, inject a synthetic user message asking the model to process the tool results and continue. Guarded by a per-tool-round flag and the global turn limit to prevent infinite loops. - Add AgentEvent::Nudge variant and UI handling - Add History::has_recent_tool_results() helper - Make Message::first_text_content() public - Add nudge detection in turn() with synthetic message injection Ported from: NousResearch/hermes-agent#10065 Addresses issue #299 (among others)
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three independent fixes in one PR:
1. Reset activity timestamp on cached agent reuse (#9051)
When the gateway reuses a cached AIAgent for a new turn,
_last_activity_tsfrom the previous turn carried over. If the session was idle for 30 minutes, the inactivity timeout handler immediately killed the fresh agent.Fix: Reset
_last_activity_ts,_last_activity_desc, and_api_call_countwhen pulling an agent from the cache (gateway/run.py +6 lines).2. Detect uv-managed virtual environments (#8620 sub-issue 1)
_detect_venv_dir()checkedsys.prefix != sys.base_prefixto find the venv. Underuv run, these are equal — uv doesn't do traditional activation. The fallback tosys.executablereturned uv's standalone Python (no site-packages), so the generated systemd ExecStart crashed.Fix: Check
VIRTUAL_ENVenv var before falling back. uv sets this even when sys.prefix is unchanged (hermes_cli/gateway.py +10 lines).Note: sub-issues 2-4 of #8620 (context_length, compression 503) are separate bugs.
3. Nudge model to continue after empty post-tool response (#9400)
Weaker models sometimes return empty after tool calls — no text, no tool_calls — silently abandoning multi-step tasks. The agent showed
↻ Empty response after tool calls — using earlier content as final answerand stopped.Fix: When the model returns empty after tool calls and there's no prior-turn content fallback, inject a one-time user nudge: "You just executed tool calls but returned an empty response. Please process the tool results above and continue with the task." Resets after each successful tool round so it can fire again on later rounds (run_agent.py +44 lines).
Test plan