The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): print the whole gateway repair hint in hermes chat
unsupportedpastels8c979a970b99
diff --git a/hermes_cli/cli_chat_error_copy.py b/hermes_cli/cli_chat_error_copy.pyindex 7457456d83d..7319da9ca05 100644--- a/hermes_cli/cli_chat_error_copy.py+++ b/hermes_cli/cli_chat_error_copy.py@@ -28,9 +28,9 @@ _REASON_KEYS: dict[str, str] = {_UNKNOWN_KEY = "unknown"-def _short(text: str, limit: int = _SUMMARY_LIMIT) -> str:+def _short(text: str, limit: int | None = _SUMMARY_LIMIT) -> str:first = (text or "").strip().splitlines()[0] if (text or "").strip() else ""- return first if len(first) <= limit else first[: limit - 1].rstrip() + "…"+ return first if limit is None or len(first) <= limit else first[: limit - 1].rstrip() + "…"def refusal_text(error: BaseException | str) -> str:@@ -80,5 +80,12 @@ def chat_error_response(def agent_init_failure_message(error: BaseException) -> str:- """Copy for a failed AIAgent build on first message: the user's turn was dropped."""- return t("cli.error.agent_init_failed", error=_short(refusal_text(error)) or type(error).__name__)+ """Copy for a failed AIAgent build on first message: the user's turn was dropped.++ A gateway that cannot be reached keeps its whole first line: its discovery detail is already+ bounded (``DiscoveryError.bounded_detail``) and ends in the repair command, which the summary+ limit would cut mid-path."""+ from hermes_cli.gateway_client import GatewayUnavailableError++ limit = None if isinstance(error, GatewayUnavailableError) else _SUMMARY_LIMIT+ return t("cli.error.agent_init_failed", error=_short(refusal_text(error), limit) or type(error).__name__)diff --git a/tests/hermes_cli/test_gateway_runtime_discovery.py b/tests/hermes_cli/test_gateway_runtime_discovery.pyindex 921b4868071..93202e86a28 100644--- a/tests/hermes_cli/test_gateway_runtime_discovery.py+++ b/tests/hermes_cli/test_gateway_runtime_discovery.py@@ -198,6 +198,35 @@ def test_the_client_verdict_names_the_unsafe_node_and_its_fix(monkeypatch, requeassert f'{shown} is owned by uid {owner}, expected uid {owner + 1}' in (verdict.detail or ''), verdict[email protected]("linux", "macos")+def test_hermes_chat_prints_the_whole_repair_command(monkeypatch, request):+ """``hermes chat`` shows a failed attach through ``agent_init_failure_message``, whose 120-character+ summary cut the hint mid-path: the whole command must reach the user."""+ import asyncio+ import shutil+ from hermes_cli.cli_chat_error_copy import agent_init_failure_message+ from hermes_cli.gateway_client import GatewayUnavailableError, connect_gateway+ root = Path(tempfile.mkdtemp(prefix='h-'))+ request.addfinalizer(lambda: shutil.rmtree(root, ignore_errors=True))+ home = root / ('profile-' + 'x' * 12)+ home.mkdir(mode=0o700)+ control = home / 'gateway.sock'+ monkeypatch.setenv('HERMES_HOME', str(home))+ monkeypatch.delenv('HERMES_TUI_GATEWAY_URL', raising=False)++ async def attach():+ async with connect_gateway():+ pass++ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as server:+ server.bind(str(control))+ control.chmod(0o660)+ with pytest.raises(GatewayUnavailableError) as unavailable:+ asyncio.run(attach())+ message = agent_init_failure_message(unavailable.value)+ assert f'chmod 600 {home.resolve() / "gateway.sock"})' in message, message++@pytest.mark.platforms("linux", "macos")def test_a_long_home_keeps_the_repair_command_whole_or_drops_it(tmp_path):"""The detail is bounded to 500 characters; a long profile home (named twice: the node and the