Skip to content

The agent that grows with you

fix(cli): a long one-sentence reasoning is not repeated as a shortened title

Teknium3b15d2800b51
diff --git a/hermes_cli/cli_modern_layout.py b/hermes_cli/cli_modern_layout.py
index f141781ffc2..096a911617d 100644
--- a/hermes_cli/cli_modern_layout.py
+++ b/hermes_cli/cli_modern_layout.py
@@ -112,21 +112,25 @@ def answer_label(timestamp: str = "") -> str:
return f"\n{separator(True)}\n{_fg(_skin_hex('ui_accent', '#FFBF00'), bold=True)}{glyph} {name}{_RST}{stamp}"
-def thought_title(text: str) -> str:
- """Short title for a reasoning block: its first ``**bold**`` heading, else its first sentence."""
+def _full_title(text: str) -> str:
+ """The reasoning's first ``**bold**`` heading, else its first sentence, whitespace-collapsed."""
text = (text or "").strip()
match = re.search(r"\*\*(.+?)\*\*", text)
title = match.group(1) if match else re.split(r"(?<=[.!?])\s|\n", text, maxsplit=1)[0]
- title = " ".join(title.split()).strip("*# ")
+ return " ".join(title.split()).strip("*# ")
+
+
+def thought_title(text: str) -> str:
+ """Short title for a reasoning block: its first ``**bold**`` heading, else its first sentence."""
+ title = _full_title(text)
return title if len(title) <= _TITLE_MAX else title[:_TITLE_MAX - 1].rstrip() + "…"
def thought_line(seconds: float | None, text: str) -> str:
"""``∴ Thought for 3s · Planning the change`` (dim italic), closing a reasoning block."""
- title = thought_title(text)
# The reasoning is printed above this line; a title that IS the whole reasoning would repeat it.
- if title and title == " ".join((text or "").split()).strip("*# "):
- title = ""
+ whole = _full_title(text) == " ".join((text or "").split()).strip("*# ")
+ title = "" if whole else thought_title(text)
took = t("cli.modern.thought_for", seconds=f"{max(seconds or 0.0, 0.0):.0f}") if seconds else t("cli.modern.thought")
body = f"{took} · {title}" if title else took
return f"\x1b[2;3m∴ {body}{_RST}"
diff --git a/tests/hermes_cli/test_cli_modern_layout.py b/tests/hermes_cli/test_cli_modern_layout.py
index 12f9e69575b..907315b84b0 100644
--- a/tests/hermes_cli/test_cli_modern_layout.py
+++ b/tests/hermes_cli/test_cli_modern_layout.py
@@ -48,7 +48,12 @@ def test_glyph_layout_scrollback_is_width_independent(monkeypatch, modern):
assert any("Added multiply to calc.py." in line for line in rows)
-def test_one_line_reasoning_is_shown_once(monkeypatch):
[email protected]("reasoning", [
+ "scripted reasoning about gamma zeta-reason",
+ # Longer than the 72-char title cap: a shortened title would still repeat it.
+ "scripted reasoning about gamma zeta-reason that keeps going well past the title length cap here",
+])
+def test_one_line_reasoning_is_shown_once(monkeypatch, reasoning):
"""Reasoning streams above its ∴ summary, so a one-sentence block must not reappear as the title."""
from cli import HermesCLI
import cli as climod
@@ -61,13 +66,14 @@ def test_one_line_reasoning_is_shown_once(monkeypatch):
monkeypatch.setattr(climod, "_cprint", lambda s: emitted.append(_plain(s)))
monkeypatch.setattr(climod, "_terminal_width_for_streaming", lambda: 100)
monkeypatch.setattr(HermesCLI, "_scrollback_box_width", lambda self: 100)
- cli._stream_reasoning_delta("scripted reasoning about gamma zeta-reason")
+ cli._stream_reasoning_delta(reasoning)
cli._stream_delta("GAMMA answered.\n")
cli._flush_stream()
- text = "\n".join(emitted)
- assert text.count("scripted reasoning about gamma zeta-reason") == 1, emitted
- assert any(line.startswith("∴") for line in text.split("\n")), emitted
+ rows = "\n".join(emitted).split("\n")
+ assert sum(row.count(reasoning) for row in rows) == 1, emitted
+ thought = [row for row in rows if row.startswith("∴")]
+ assert len(thought) == 1 and "·" not in thought[0], thought
@pytest.mark.parametrize("modern", [True, False])