The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
gateway status shows why an unset-default gateway stayed standalone
teknium10a1716cb27a3
diff --git a/gateway/status.py b/gateway/status.pyindex 0e131a3e872..7f760f42783 100644--- a/gateway/status.py+++ b/gateway/status.py@@ -806,6 +806,7 @@ def write_runtime_status(active_agents: Any = _UNSET, active_work: Any = _UNSET, platform: Any = _UNSET, platform_state: Any = _UNSET,error_code: Any = _UNSET, error_message: Any = _UNSET, needs_attention: Any = _UNSET,retrying_since: Any = _UNSET, served_profiles: Any = _UNSET, session_store: Any = _UNSET,+ multiplex_standalone_reason: Any = _UNSET,ingress_url: Any = _UNSET, listener_base: Any = _UNSET, clear_profile_platforms: bool = False,drop_profile_platforms: Optional[str] = None,) -> None:@@ -838,6 +839,8 @@ def write_runtime_status(("active_work", active_work, lambda v: list(v) if v else None),# Multiplexed profiles; absent/empty for a single-profile gateway.("served_profiles", served_profiles, lambda v: list(v or [])),+ # Why an unset-default (multiplex on) gateway is serving one profile; None clears it.+ ("multiplex_standalone_reason", multiplex_standalone_reason, lambda v: str(v) if v else None),("session_store", session_store, _coerce_session_store),))if platform is not _UNSET:diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.pyindex 19c0e7c7ea8..75de5dc1aea 100644--- a/hermes_cli/gateway.py+++ b/hermes_cli/gateway.py@@ -1482,6 +1482,19 @@ def _print_gateway_process_mismatch(snapshot: GatewayRuntimeSnapshot) -> None:print(" can refuse to start another copy until this process stops.")+def _print_multiplex_standalone_reason() -> None:+ """The boot guard kept an unset-default gateway standalone: say so in status, with the remedy."""+ try:+ from gateway.status import read_runtime_status+ reason = (read_runtime_status() or {}).get("multiplex_standalone_reason")+ except Exception:+ return+ if reason:+ print(f"⚠ Serving the default profile only (gateway.multiplex_profiles unset): {reason}")+ print(" Fold every profile onto this gateway: hermes gateway migrate --multiplex")+ print(" Keep per-profile gateways: hermes config set gateway.multiplex_profiles false")++def _print_served_ingress_urls(profile: str | None = None) -> None:"""Callback URLs of inbound-port platforms the live multiplexer serves for secondary profiles(the value to paste into the Twilio / LINE / Teams / BlueBubbles console)."""@@ -6421,6 +6434,7 @@ def _cmd_status(args):else:_gw_windows().status(deep=deep)_print_gateway_process_mismatch(snapshot)+ _print_multiplex_standalone_reason()_print_served_ingress_urls()else:pids = list(snapshot.gateway_pids)@@ -6428,6 +6442,7 @@ def _cmd_status(args):print(f"✓ Gateway is running (PID: {', '.join(map(str, pids))})")print(" (Running manually, not as a system service)")_print_runtime_health()+ _print_multiplex_standalone_reason()_print_served_ingress_urls()print()_print_lines(*_STATUS_RUNNING_HINTS[_status_host_kind()])diff --git a/hermes_cli/gateway_multiplex_mode.py b/hermes_cli/gateway_multiplex_mode.pyindex b07ad0409c4..0c7133bb883 100644--- a/hermes_cli/gateway_multiplex_mode.py+++ b/hermes_cli/gateway_multiplex_mode.py@@ -123,7 +123,18 @@ def resolve_multiplex_mode(config) -> MultiplexDecision:return decision+def record_multiplex_decision(decision: MultiplexDecision) -> None:+ """Persist a guard refusal into ``gateway_state.json`` so `hermes gateway status` can show why this+ gateway serves one profile while the default says multiplex; any other verdict clears the field."""+ try:+ from gateway.status import write_runtime_status+ write_runtime_status(multiplex_standalone_reason=decision.reason if decision.source == "guard" else None)+ except Exception:+ logger.debug("could not record the multiplex decision", exc_info=True)++def log_multiplex_decision(decision: MultiplexDecision) -> None:+ record_multiplex_decision(decision)if decision.source == "config" and not decision.enabled:logger.info("gateway.multiplex_profiles is false: serving this profile only ""(hermes gateway migrate --multiplex folds every profile onto the default gateway).")diff --git a/tests/hermes_cli/test_gateway_multiplex_mode.py b/tests/hermes_cli/test_gateway_multiplex_mode.pyindex 0afb4f898a7..73b22323f57 100644--- a/tests/hermes_cli/test_gateway_multiplex_mode.py+++ b/tests/hermes_cli/test_gateway_multiplex_mode.py@@ -135,3 +135,15 @@ def test_live_record_outranks_the_raw_flag_for_other_processes(fleet, monkeypatcrecord["served_profiles"] = ["default", "coder", "ops"](root / "gateway_state.json").write_text(json.dumps(record))assert mode.default_gateway_multiplexes(root) is True+++def test_guard_refusal_is_recorded_in_runtime_status_and_cleared_on_default(tmp_path, monkeypatch):+ """A guard refusal must be visible to `hermes gateway status`, not only in the boot log; a later+ boot that multiplexes clears it (a stale reason would misdescribe the live gateway)."""+ from gateway import status as gw_status+ from hermes_cli.gateway_multiplex_mode import MultiplexDecision, record_multiplex_decision+ monkeypatch.setattr(gw_status, "_get_runtime_status_path", lambda: tmp_path / "gateway_state.json")+ record_multiplex_decision(MultiplexDecision(False, "guard", "profile(s) 'coder' still run their own gateway"))+ assert "coder" in gw_status.read_runtime_status(tmp_path / "gateway_state.json")["multiplex_standalone_reason"]+ record_multiplex_decision(MultiplexDecision(True, "default", "unset; default applies"))+ assert gw_status.read_runtime_status(tmp_path / "gateway_state.json")["multiplex_standalone_reason"] is None