The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): don't re-render an interrupted reply streamed before a tool-call transition (#65666)
kshitijk4poor4889fa924ecb
diff --git a/hermes_cli/cli_chat_turn_mixin.py b/hermes_cli/cli_chat_turn_mixin.pyindex a7da8013cfe..9a86e8180ca 100644--- a/hermes_cli/cli_chat_turn_mixin.py+++ b/hermes_cli/cli_chat_turn_mixin.py@@ -106,6 +106,7 @@ class CLIChatTurnMixin:# Not part of _reset_stream_state: must persist across intermediate turn# boundaries (tool-calling loops), reset once per user turn.self._reasoning_shown_this_turn = False+ self._response_streamed_this_turn = Falseself._chat_setup_turn_audio(turn, message, voice_input)# Per-prompt elapsed timer — frozen when the agent thread finishes.self._prompt_start_time = time.time()@@ -680,7 +681,10 @@ class CLIChatTurnMixin:_resp_text = _maybe_remap_for_light_mode("#FFF8DC")is_error_response = turn.result and (turn.result.get("failed") or turn.result.get("partial"))- already_streamed = self._stream_started and self._stream_box_opened and not is_error_response+ already_streamed = (+ (self._stream_started and self._stream_box_opened)+ or getattr(self, "_response_streamed_this_turn", False)+ ) and not is_error_responseif turn.use_streaming_tts and turn.box_opened and not is_error_response:# Text already printed sentence-by-sentence; just close the box._cprint(f"\n{_ACCENT}╰{'─' * (self._scrollback_box_width() - 2)}╯{_RST}")diff --git a/hermes_cli/cli_stream_mixin.py b/hermes_cli/cli_stream_mixin.pyindex 30b41d6fc75..ab1709f592e 100644--- a/hermes_cli/cli_stream_mixin.py+++ b/hermes_cli/cli_stream_mixin.py@@ -428,6 +428,8 @@ class CLIStreamMixin:if not text:returnself._stream_box_opened = True+ # Turn-level: survives _reset_stream_state at tool-call boundaries (#65666).+ self._response_streamed_this_turn = Trueself._stream_box_live = True # header drawn; cleared at the footertry:from hermes_cli.skin_engine import get_active_skindiff --git a/tests/hermes_cli/test_status_lines_held_during_stream_box.py b/tests/hermes_cli/test_status_lines_held_during_stream_box.pyindex a9ac24c32a4..6ff5fec9bb2 100644--- a/tests/hermes_cli/test_status_lines_held_during_stream_box.py+++ b/tests/hermes_cli/test_status_lines_held_during_stream_box.py@@ -74,3 +74,14 @@ def test_status_line_prints_immediately_outside_a_box(cli_stub):cli._agent_status_print(" ✓ [set 1 · 1/1] worker (3.0s)")assert [_plain(e) for e in emitted] == [" ✓ [set 1 · 1/1] worker (3.0s)"]assert not getattr(cli, "_held_status_lines", [])+++def test_streamed_flag_survives_tool_call_boundary(cli_stub):+ """#65666: the chat-turn 'already streamed' guard must still see the reply after a tool-call+ boundary resets per-segment stream state, or an interrupted reply is re-rendered as a Panel."""+ cli, _ = cli_stub+ cli._response_streamed_this_turn = False+ cli._stream_delta("Partial answer.\n")+ cli._stream_delta(None) # tool-call boundary: flush + per-segment reset+ assert cli._stream_box_opened is False+ assert cli._response_streamed_this_turn is True