Skip to content

fix: prevent premature loop exit when weak models return empty after substantive tool calls#10472

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

fix: prevent premature loop exit when weak models return empty after substantive tool calls#10472
teknium1 merged 1 commit into
mainfrom
hermes/hermes-47969688

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Fixes the ↻ Empty response after tool calls — using earlier content as final answer premature exit that users with weaker models (xiaomi/mimo-v2-pro, GLM-5, etc.) are hitting.

The bug: The _last_content_with_tools fallback fires for ALL turns where the model returns content alongside tool calls — including mid-task narration like "I'm going to scan the directory..." alongside terminal(ls). When the weak model then returns empty on the next turn (a known behavior), the fallback immediately uses that narration as the "final answer" and exits the loop. The post-tool nudge mechanism (designed specifically for this weak-model scenario) never gets a chance to fire because the fallback preempts it.

The fix: Only use the _last_content_with_tools fallback when ALL tools in the turn were housekeeping (memory, todo, skill_manage, session_search) — where the content genuinely IS the final answer (e.g. "You're welcome!" + memory save). When substantive tools are present (terminal, search_files, etc.), skip the fallback and let the post-tool nudge prompt the model to continue processing.

Control flow (before)

Model returns empty →
  1. Check partial stream recovery (no)
  2. Check _last_content_with_tools fallback → YES, fires, exits loop ← BUG
  3. Post-tool nudge → never reached

Control flow (after)

Model returns empty →
  1. Check partial stream recovery (no)
  2. Check _last_content_with_tools fallback → only if ALL tools were housekeeping
  3. Post-tool nudge → fires for substantive tool cases, model continues

Changes

  • Track _last_content_tools_all_housekeeping flag alongside _last_content_with_tools
  • Guard the fallback exit with the housekeeping check
  • Clear stale narration when the nudge fires
  • Reset flag on compression and turn boundaries

Test plan

  • 764 passed, 2 failed (pre-existing, unrelated KeyError in provider parity tests)
  • The partial stream recovery preemption test continues to pass
  • Housekeeping fallback path unchanged (memory + todo still exits cleanly)
  • Substantive tool path now falls through to the post-tool nudge

Reported by user Renaissance on Discord.

…substantive tool calls

The _last_content_with_tools fallback was firing indiscriminately for ALL
content+tool turns, including mid-task narration alongside substantive
tools (terminal, search_files, etc.).  This caused the agent to exit
the loop with 'I'll scan the directory...' as the final answer instead
of nudging the model to continue processing tool results.

The fix restricts the fallback to housekeeping-only turns (memory, todo,
skill_manage, session_search) where the content genuinely IS the final
answer.  When substantive tools are present, the existing post-tool
nudge mechanism now fires instead, prompting the model to continue.

Affected models: xiaomi/mimo-v2-pro, GLM-5, and other weaker models
that intermittently return empty after tool results.

Reported by user Renaissance on Discord.
@teknium1 teknium1 merged commit 0d25e1c into main Apr 15, 2026
6 of 7 checks passed
@teknium1 teknium1 deleted the hermes/hermes-47969688 branch April 15, 2026 20:28
kagura-agent pushed a commit to kagura-agent/hermes-agent that referenced this pull request Apr 16, 2026
…substantive tool calls (NousResearch#10472)

The _last_content_with_tools fallback was firing indiscriminately for ALL
content+tool turns, including mid-task narration alongside substantive
tools (terminal, search_files, etc.).  This caused the agent to exit
the loop with 'I'll scan the directory...' as the final answer instead
of nudging the model to continue processing tool results.

The fix restricts the fallback to housekeeping-only turns (memory, todo,
skill_manage, session_search) where the content genuinely IS the final
answer.  When substantive tools are present, the existing post-tool
nudge mechanism now fires instead, prompting the model to continue.

Affected models: xiaomi/mimo-v2-pro, GLM-5, and other weaker models
that intermittently return empty after tool results.

Reported by user Renaissance on Discord.
ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
…substantive tool calls (NousResearch#10472)

The _last_content_with_tools fallback was firing indiscriminately for ALL
content+tool turns, including mid-task narration alongside substantive
tools (terminal, search_files, etc.).  This caused the agent to exit
the loop with 'I'll scan the directory...' as the final answer instead
of nudging the model to continue processing tool results.

The fix restricts the fallback to housekeeping-only turns (memory, todo,
skill_manage, session_search) where the content genuinely IS the final
answer.  When substantive tools are present, the existing post-tool
nudge mechanism now fires instead, prompting the model to continue.

Affected models: xiaomi/mimo-v2-pro, GLM-5, and other weaker models
that intermittently return empty after tool results.

Reported by user Renaissance on Discord.
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
…substantive tool calls (NousResearch#10472)

The _last_content_with_tools fallback was firing indiscriminately for ALL
content+tool turns, including mid-task narration alongside substantive
tools (terminal, search_files, etc.).  This caused the agent to exit
the loop with 'I'll scan the directory...' as the final answer instead
of nudging the model to continue processing tool results.

The fix restricts the fallback to housekeeping-only turns (memory, todo,
skill_manage, session_search) where the content genuinely IS the final
answer.  When substantive tools are present, the existing post-tool
nudge mechanism now fires instead, prompting the model to continue.

Affected models: xiaomi/mimo-v2-pro, GLM-5, and other weaker models
that intermittently return empty after tool results.

Reported by user Renaissance on Discord.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…substantive tool calls (NousResearch#10472)

The _last_content_with_tools fallback was firing indiscriminately for ALL
content+tool turns, including mid-task narration alongside substantive
tools (terminal, search_files, etc.).  This caused the agent to exit
the loop with 'I'll scan the directory...' as the final answer instead
of nudging the model to continue processing tool results.

The fix restricts the fallback to housekeeping-only turns (memory, todo,
skill_manage, session_search) where the content genuinely IS the final
answer.  When substantive tools are present, the existing post-tool
nudge mechanism now fires instead, prompting the model to continue.

Affected models: xiaomi/mimo-v2-pro, GLM-5, and other weaker models
that intermittently return empty after tool results.

Reported by user Renaissance on Discord.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…substantive tool calls (NousResearch#10472)

The _last_content_with_tools fallback was firing indiscriminately for ALL
content+tool turns, including mid-task narration alongside substantive
tools (terminal, search_files, etc.).  This caused the agent to exit
the loop with 'I'll scan the directory...' as the final answer instead
of nudging the model to continue processing tool results.

The fix restricts the fallback to housekeeping-only turns (memory, todo,
skill_manage, session_search) where the content genuinely IS the final
answer.  When substantive tools are present, the existing post-tool
nudge mechanism now fires instead, prompting the model to continue.

Affected models: xiaomi/mimo-v2-pro, GLM-5, and other weaker models
that intermittently return empty after tool results.

Reported by user Renaissance on Discord.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…substantive tool calls (NousResearch#10472)

The _last_content_with_tools fallback was firing indiscriminately for ALL
content+tool turns, including mid-task narration alongside substantive
tools (terminal, search_files, etc.).  This caused the agent to exit
the loop with 'I'll scan the directory...' as the final answer instead
of nudging the model to continue processing tool results.

The fix restricts the fallback to housekeeping-only turns (memory, todo,
skill_manage, session_search) where the content genuinely IS the final
answer.  When substantive tools are present, the existing post-tool
nudge mechanism now fires instead, prompting the model to continue.

Affected models: xiaomi/mimo-v2-pro, GLM-5, and other weaker models
that intermittently return empty after tool results.

Reported by user Renaissance on Discord.
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