Skip to content

fix: stale agent timeout, uv venv detection, empty response after tools (#9051, #8620, #9400) - #10065

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-a8920bf7
Apr 15, 2026
Merged

fix: stale agent timeout, uv venv detection, empty response after tools (#9051, #8620, #9400)#10065
teknium1 merged 1 commit into
mainfrom
hermes/hermes-a8920bf7

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

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_ts from 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_count when pulling an agent from the cache (gateway/run.py +6 lines).

2. Detect uv-managed virtual environments (#8620 sub-issue 1)

_detect_venv_dir() checked sys.prefix != sys.base_prefix to find the venv. Under uv run, these are equal — uv doesn't do traditional activation. The fallback to sys.executable returned uv's standalone Python (no site-packages), so the generated systemd ExecStart crashed.

Fix: Check VIRTUAL_ENV env 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 answer and 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

  • 97 gateway + CLI tests pass
  • 9 venv detection tests pass
  • All 3 changes compile clean

@teknium1
teknium1 force-pushed the hermes/hermes-a8920bf7 branch from b16085a to 1c56247 Compare April 15, 2026 04:24
…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
teknium1 force-pushed the hermes/hermes-a8920bf7 branch from 1c56247 to f23edda Compare April 15, 2026 04:32
@teknium1
teknium1 merged commit 50c35dc into main Apr 15, 2026
6 of 7 checks passed
@teknium1
teknium1 deleted the hermes/hermes-a8920bf7 branch April 15, 2026 05:16
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant