mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
fix: resolve UnboundLocalError in post-tool empty response nudge path
When a model returns an empty response after tool calls with no new tool_calls in the follow-up turn, the code enters the "nudge" recovery path which referenced `assistant_msg` before it was assigned. This variable is only set in the tool-calls branch (line 10098), but the nudge code lives in the no-tool-calls branch (line 10263+). The fix builds a fresh assistant message dict via `_build_assistant_message()` instead of reusing the unbound variable, consistent with the exhausted- retries path at line 10457.
This commit is contained in:
@@ -10945,8 +10945,9 @@ class AIAgent:
|
||||
# tool(result) → assistant("(empty)") → user(nudge)
|
||||
# Without this, we'd have tool → user which most
|
||||
# APIs reject as an invalid sequence.
|
||||
assistant_msg["content"] = "(empty)"
|
||||
messages.append(assistant_msg)
|
||||
_nudge_msg = self._build_assistant_message(assistant_message, finish_reason)
|
||||
_nudge_msg["content"] = "(empty)"
|
||||
messages.append(_nudge_msg)
|
||||
messages.append({
|
||||
"role": "user",
|
||||
"content": (
|
||||
|
||||
Reference in New Issue
Block a user