The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(messaging): ignore a served profile's stale own runtime record
liuhao10241db1303964b0
diff --git a/hermes_cli/web_routers/messaging.py b/hermes_cli/web_routers/messaging.pyindex 4e98867730b..3a6a3b9dd13 100644--- a/hermes_cli/web_routers/messaging.py+++ b/hermes_cli/web_routers/messaging.py@@ -278,14 +278,15 @@ def _platform_payloads(scoped_dir: Optional[Path], entries) -> list[dict[str, AnHERMES_HOME contextvar; the gateway status readers do not, hence the explicit path)."""env_on_disk = load_env()runtime = read_runtime_status(path=scoped_dir / "gateway_state.json") if scoped_dir is not None else read_runtime_status()- if runtime is None:- # A profile served by the multiplexer writes no record of its own; its adapters live in the- # multiplexer's record under ``<profile>:<platform>``. Unscoped, the profile is the process's- # own home (a pooled ``hermes --profile X serve``); the default home resolves to None here.- own_home = scoped_dir if scoped_dir is not None else get_process_hermes_home()- served = multiplexer_liveness_for_profile(own_home)- if served is not None:- runtime = {**served[1], "platforms": profile_platforms_from_multiplexer(served[1], own_home.name)}+ # A profile the live multiplexer serves runs no gateway of its own, so its own+ # gateway_state.json — a leftover from a pre-multiplex or standalone run — is always history,+ # never current state; it must not shadow the multiplexer's authoritative record. Unscoped,+ # the profile is the process's own home (a pooled ``hermes --profile X serve``); the default+ # home resolves to None here.+ own_home = scoped_dir if scoped_dir is not None else get_process_hermes_home()+ served = multiplexer_liveness_for_profile(own_home)+ if served is not None:+ runtime = {**served[1], "platforms": profile_platforms_from_multiplexer(served[1], own_home.name)}return [_messaging_platform_payload(entry, env_on_disk, runtime, scoped=scoped_dir is not None, profile_home=scoped_dir)for entry in entries]diff --git a/tests/hermes_cli/test_served_profile_mirror_platforms.py b/tests/hermes_cli/test_served_profile_mirror_platforms.pyindex 192379fd9fa..d101ecdd188 100644--- a/tests/hermes_cli/test_served_profile_mirror_platforms.py+++ b/tests/hermes_cli/test_served_profile_mirror_platforms.py@@ -64,3 +64,20 @@ def test_messaging_card_for_a_served_profile_reads_connected_not_restart_needed(assert payload["gateway_running"] is Trueassert payload["state"] == "connected", payloadassert payload["ingress_url"] == "http://127.0.0.1:45719/p/alpha/v1"+++def test_messaging_card_ignores_a_served_profiles_stale_own_runtime_record(served_root, monkeypatch):+ """A served profile writes no live ``gateway_state.json`` of its own, but one left behind by a+ pre-multiplex or standalone run (``stopped``, empty platforms) used to shadow the multiplexer's+ record: the fallback only ran when the file was missing, the bare-key lookup found nothing, and+ the card read "Restart needed" forever for a platform that was connected (#112765)."""+ from hermes_cli.web_routers import messaging+ monkeypatch.setattr(messaging, "_platform_enablement", lambda *a, **k: (True, True, None))+ entry = {"id": "telegram", "name": "Telegram", "description": "", "docs_url": "", "env_vars": [],+ "required_env": []}+ alpha = served_root / "profiles" / "alpha"+ (alpha / "gateway_state.json").write_text(json.dumps(+ {"gateway_state": "stopped", "platforms": {}}))+ [payload] = messaging._platform_payloads(alpha, [entry])+ assert payload["gateway_running"] is True+ assert payload["state"] == "connected", payload