Skip to content

The agent that grows with you

fix(display): one fallback-row source for tools without a renderer

Teknium86fa9e6ca1de
diff --git a/agent/display.py b/agent/display.py
index 6003b53f334..590be47d763 100644
--- a/agent/display.py
+++ b/agent/display.py
@@ -1102,6 +1102,14 @@ def _cute_row(emoji: str, verb: str, detail: str = "") -> str:
return _CuteRow(f"┊ {emoji} {label:9} {detail}", emoji, label, detail)
+def _cute_fallback_row(tool_name: str, args: dict) -> _CuteRow:
+ """The row for a tool with no dedicated renderer: its registered (or skin) emoji, its name, and
+ its preview. One source for both layouts, so their icons can't drift."""
+ detail = _cute_trunc(build_tool_preview(tool_name, args) or "")
+ emoji = get_tool_emoji(tool_name)
+ return _CuteRow(f"┊ {emoji} {tool_name[:9]:9} {detail}", emoji, tool_name, detail)
+
+
def get_tool_row_parts(tool_name: str, args: dict | None, result: str | None = None, *, is_error: bool = False):
"""``[(emoji, verb, detail, failure), ...]`` for one completed call: the parts the ``┊`` line
uses, without its padding. ``failure`` is None for a row that succeeded, else that row's
@@ -1120,10 +1128,8 @@ def get_tool_row_parts(tool_name: str, args: dict | None, result: str | None = N
for lb, mark in zip(labels, marks)]
render = _CUTE_LINES.get(tool_name)
row = render(args, result) if render else None
- if isinstance(row, _CuteRow):
- return [(row.emoji, row.verb, row.detail, call_failure)]
- return [(get_tool_emoji(tool_name), tool_name, _cute_trunc(build_tool_preview(tool_name, args) or ""),
- call_failure)]
+ row = row if isinstance(row, _CuteRow) else _cute_fallback_row(tool_name, args)
+ return [(row.emoji, row.verb, row.detail, call_failure)]
except Exception:
logger.debug("Tool row parts failed for %s", tool_name, exc_info=True)
return [("⚡", str(tool_name), "", None)]
@@ -1302,7 +1308,7 @@ def _get_cute_tool_message(tool_name: str, args: dict, duration: float, result:
render = _CUTE_LINES.get(tool_name)
rows = _cute_bridge_rows(tool_name, args)
if rows is None:
- body = render(args, result) if render else f"┊ ⚡ {tool_name[:9]:9} {_cute_trunc(build_tool_preview(tool_name, args) or '')}"
+ body = render(args, result) if render else _cute_fallback_row(tool_name, args)
rows, suffixes = [body], [failure_suffix if is_failure else ""]
else:
suffixes = _bridge_row_suffixes(len(rows), result, failure_suffix if is_failure else "")
diff --git a/tests/hermes_cli/test_cli_modern_layout.py b/tests/hermes_cli/test_cli_modern_layout.py
index 43c51da5e3a..fff8f9e1ad2 100644
--- a/tests/hermes_cli/test_cli_modern_layout.py
+++ b/tests/hermes_cli/test_cli_modern_layout.py
@@ -172,8 +172,9 @@ def test_tool_rows_keep_the_classic_tool_emoji():
from agent.display import get_cute_tool_message
from hermes_cli.cli_modern_layout import tool_row
+ # clarify has no dedicated renderer: both layouts take its registered emoji from one source.
for name, args in (("read_file", {"path": "/etc/hostname"}), ("terminal", {"command": "echo ok"}),
- ("execute_code", {"code": "import math"})):
+ ("execute_code", {"code": "import math"}), ("clarify", {"question": "Which?"})):
classic_emoji = get_cute_tool_message(name, args, 0.2).split()[1]
assert _plain(tool_row(name, args, 0.2)).startswith(classic_emoji + " "), (name, classic_emoji)
failed = _plain(tool_row("terminal", {"command": "false"}, 0.2, result='{"exit_code": 1, "output": ""}'))