mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00: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:
parent
9f231dae56
commit
85752791ed
1 changed files with 3 additions and 2 deletions
|
|
@ -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": (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue