Skip to content

[Bug]: Empty final response after tool calls can hit unbound assistant_msg path #17248

Description

@zhou-shiliu

Bug Description

After successful tool calls, Hermes sometimes emits no assistant response at all in CLI chats. The terminal logs show retries with Model returned empty after tool calls, followed by an internal exception:

cannot access local variable 'assistant_msg' where it is not associated with a value

From the user perspective, the agent appears to go silent mid-task even though the tools actually ran.

Steps to Reproduce

  1. Use Hermes in CLI chat mode with an OpenAI-compatible provider/model (observed on gpt-5.4 via custom provider).
  2. Run a multi-step task that includes several tool calls and then needs a natural-language wrap-up.
  3. Observe that tools succeed, but Hermes occasionally returns an empty final response.
  4. Hermes retries automatically, then still returns no content.

Expected Behavior

After tool calls complete, Hermes should always produce either:

  • a normal assistant message, or
  • a clear structured error message

It should not silently drop the reply or reference an uninitialized assistant_msg variable.

Actual Behavior

Observed log/output:

Model returned empty after tool calls — nudging to continue
Error during OpenAI-compatible API call #1: cannot access local variable 'assistant_msg' where it is not associated with a value
Empty response from model — retrying (1/3)
Empty response from model — retrying (2/3)
Empty response from model — retrying (3/3)
Model returned no content after all retries. No fallback providers configured.

Why this seems like a Hermes bug

  • Tool calls did execute successfully.
  • Failure happens when Hermes is trying to assemble/send the assistant reply after tool execution.
  • The error strongly suggests a response-construction code path where assistant_msg is referenced before assignment.

Environment

  • Platform: Hermes CLI
  • Model: gpt-5.4
  • Provider: custom OpenAI-compatible provider
  • Session type: normal chat with developer tools/tool calls
  • Date observed: 2026-04-29

Notes

A related symptom is that the agent may appear to "freeze" or "stop talking" mid-task, but the actual root issue seems to be empty-response handling after tool calls rather than tool execution itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointsweeper:implemented-on-mainSweeper: behavior already present on current maintype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions