The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): status flags a running gateway this Hermes cannot attach to
Teknium81922d0cb7ec
diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.pyindex f97a38bc42a..093c22c4b5a 100644--- a/hermes_cli/gateway.py+++ b/hermes_cli/gateway.py@@ -5601,6 +5601,25 @@ def _status_host_kind() -> str:return "windows" if is_windows() else "other"+def _incompatible_owner_verdict() -> str | None:+ """``incompatible: <reason>`` when the gateway answering for this home is one this Hermes's clients+ (TUI, Desktop, chat) refuse, e.g. an older Hermes's daemon left running across an upgrade."""+ try:+ from hermes_cli.gateway_runtime import discover_gateway_endpoint+ observed = discover_gateway_endpoint(get_hermes_home(), timeout=1.5)+ except Exception:+ return None+ if observed.state != "incompatible":+ return None+ return f"incompatible: {observed.reason_code or 'unknown'}"+++def _print_incompatible_owner_hint() -> None:+ print(" It was started by another Hermes version; TUI, Desktop and chat cannot attach to it.")+ print(" Replace it with this version:")+ print(" hermes gateway restart")++def _cmd_status(args):from hermes_cli.gateway_profile_lifecycle import print_parked_statusdeep = getattr(args, "deep", False)@@ -5634,11 +5653,18 @@ def _cmd_status(args):else:_gw_windows().status(deep=deep)_print_gateway_process_mismatch(snapshot)+ if stale := _incompatible_owner_verdict():+ print(f"✗ The running gateway cannot serve this Hermes ({stale})")+ _print_incompatible_owner_hint()_print_multiplex_standalone_reason()_print_served_ingress_urls()else:pids = list(snapshot.gateway_pids)- if pids:+ if pids and (stale := _incompatible_owner_verdict()):+ # An older Hermes's gateway: alive, but no client of this version can attach to it.+ print(f"✗ Gateway is running (PID: {', '.join(map(str, pids))}) but cannot serve this Hermes ({stale})")+ _print_incompatible_owner_hint()+ elif pids:print(f"✓ Gateway is running (PID: {', '.join(map(str, pids))})")print(" (Running manually, not as a system service)")_print_runtime_health()diff --git a/tests/hermes_cli/test_gateway_multiplex_lifecycle.py b/tests/hermes_cli/test_gateway_multiplex_lifecycle.pyindex faaf5a9046d..b80b31decb5 100644--- a/tests/hermes_cli/test_gateway_multiplex_lifecycle.py+++ b/tests/hermes_cli/test_gateway_multiplex_lifecycle.py@@ -252,3 +252,27 @@ def test_parked_status_still_reports_a_forced_gateway(homes, monkeypatch, capsysoutput = capsys.readouterr().outassert 'parked (hermes -p worker gateway start)' in outputassert 'Gateway is running (PID: 4242)' in output++[email protected]('verdict, healthy', [+ (('incompatible', 'runtime_protocol'), False), # an older Hermes's daemon left running+ (('ready', None), True),+])+def test_status_flags_a_gateway_this_hermes_cannot_attach(homes, monkeypatch, capsys, verdict, healthy):+ """Upgrade with the old daemon up: every client refuses it, so status must not say ✓."""+ from hermes_cli import gateway as gw, gateway_runtime, profiles+ root, _secondary = homes+ monkeypatch.setenv('HERMES_HOME', str(root))+ monkeypatch.setattr(gw, '_current_profile_name', lambda: 'default')+ monkeypatch.setattr(profiles, 'get_active_profile_name', lambda: 'default')+ monkeypatch.setattr(gw, 'get_gateway_runtime_snapshot', lambda system=False: gw.GatewayRuntimeSnapshot(+ manager='manual', gateway_pids=(4242,)))+ monkeypatch.setattr(gw, 'named_profile_served_by_running_multiplexer', lambda: False)+ monkeypatch.setattr(gw, '_installed_service_kind_for', lambda _check: None)+ monkeypatch.setattr(gateway_runtime, 'discover_gateway_endpoint', lambda home, timeout=2.0: (+ gateway_runtime.GatewayDiscovery(verdict[0], reason_code=verdict[1])))+ gw._cmd_status(SimpleNamespace())+ output = capsys.readouterr().out+ assert ('✓ Gateway is running (PID: 4242)' in output) is healthy+ assert ('incompatible: runtime_protocol' in output) is not healthy+ assert ('hermes gateway restart' in output) is not healthy