The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): keep the default's flat platforms in the multiplexer re-key (#123088, #123869, salvage #123106)
teknium135e0cac79b75
diff --git a/gateway/status.py b/gateway/status.pyindex 858ddcc752f..dfd41a3a8f2 100644--- a/gateway/status.py+++ b/gateway/status.py@@ -1498,10 +1498,10 @@ def profile_platforms_from_multiplexer(runtime: Optional[dict[str, Any]], profilown = {key[len(prefix):]: value for key, value in plats.items()if isinstance(key, str) and key.startswith(prefix) and isinstance(value, dict)}if profile == "default":- # The record's flat keys ARE the default's own adapters — only secondaries get the- # ``<profile>:`` prefix — so the standalone shape promised above is the flat map itself.- # Without this arm, readers that re-key through this helper (``/api/status``) reported no- # platforms at all for the one profile the multiplexer records un-prefixed (#123088).+ # The flat keys ARE the default's own adapters (a multiplex host's primary map is always+ # ``default``, whoever launched it; a standalone gateway writes only flat keys). Dropping+ # them projected ``{}`` for the one profile the record never prefixes → "Restart needed"+ # forever on /api/status and the Messaging card (#123088, #123869).own.update({key: value for key, value in plats.items()if isinstance(key, str) and ":" not in key and isinstance(value, dict)})return {**shared_listener_mirror_platforms(runtime, profile), **own}diff --git a/hermes_cli/web_routers/messaging.py b/hermes_cli/web_routers/messaging.pyindex d30375aa59c..1c51889393c 100644--- a/hermes_cli/web_routers/messaging.py+++ b/hermes_cli/web_routers/messaging.py@@ -302,16 +302,10 @@ def _platform_payloads(scoped_dir: Optional[Path], entries) -> list[dict[str, An):served = multiplexer_liveness_for_profile(own_home)if served is not None:- # The fold keys on the profile NAME rung 4 just proved served; ``own_home.name`` is only- # the directory basename (".hermes" or any custom HERMES_HOME name for the default root,- # the profile id only for secondaries under profiles/<name>) — the default's flat keys- # then never matched and the card read "Restart needed" forever (#123088).- runtime = {- **served[1],- "platforms": profile_platforms_from_multiplexer(- served[1], profile_name_for_home(own_home) or "default"- ),- }+ # Fold on the profile NAME, not ``own_home.name``: the default root's basename is+ # ``.hermes`` (or any custom HERMES_HOME), so its flat keys never matched (#123088).+ served_name = profile_name_for_home(own_home) or "default"+ runtime = {**served[1], "platforms": profile_platforms_from_multiplexer(served[1], served_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/hermes_cli/web_routers/status.py b/hermes_cli/web_routers/status.pyindex 6309c7c6787..a6d037ea5ca 100644--- a/hermes_cli/web_routers/status.py+++ b/hermes_cli/web_routers/status.py@@ -308,11 +308,8 @@ async def _resolve_gateway_status(profile_dir: Optional[Path], health_url) -> Di# Served by the multiplexer: its record is this profile's runtime, with the profile's own# adapters under ``<profile>:<platform>`` re-keyed to the standalone shape. Unscoped, the# profile is the process's own home (a pooled ``hermes --profile X serve``).- # The fold keys on the profile NAME, never the directory basename: scoped to "default" the- # resolved dir IS the root (".hermes" or any custom HERMES_HOME name), so ``profile_dir.name``- # never matched — the scoped readout kept ``gateway_platforms: {}`` while bare /api/status- # was already fixed, and the basename read as a named id, fabricating ``/p/<basename>/``- # mirror URLs (#123088, same defect as the messaging call site).+ # Fold on the profile NAME, never ``profile_dir.name``: ``?profile=default`` resolves the+ # root itself, whose basename (``.hermes``) matched nothing and read as a named id (#123088).served_name = profile_name_for_home(profile_dir or get_process_hermes_home())runtime = {**liveness.runtime,"platforms": profile_platforms_from_multiplexer(liveness.runtime, served_name or "")}diff --git a/tests/hermes_cli/test_served_profile_mirror_platforms.py b/tests/hermes_cli/test_served_profile_mirror_platforms.pyindex 4b926ae4c6f..6f712064724 100644--- a/tests/hermes_cli/test_served_profile_mirror_platforms.py+++ b/tests/hermes_cli/test_served_profile_mirror_platforms.py@@ -74,8 +74,13 @@ def test_default_profile_keeps_its_flat_adapters_when_rekeyed(served_root):"""The default's own adapters are the record's FLAT keys (only secondaries get the``<profile>:`` prefix), so re-keying the multiplexer record for ``default`` must keep them:``/api/status`` used to report ``gateway_platforms: {}`` for the default profile under- ``gateway.multiplex_profiles`` while its adapters were connected and delivering (#123088)."""+ ``gateway.multiplex_profiles`` while its adapters were connected and delivering (#123088).+ A STANDALONE record (``served_profiles: []``, flat keys only) reaches the same re-key through+ the multiplexer rung and must come back unchanged too (#123869)."""from gateway.status import profile_platforms_from_multiplexer, resolve_gateway_liveness+ standalone = {"gateway_state": "running", "served_profiles": [],+ "platforms": {"feishu": {"state": "connected"}}}+ assert profile_platforms_from_multiplexer(standalone, "default") == {"feishu": {"state": "connected"}}alpha = served_root / "profiles" / "alpha"live = resolve_gateway_liveness(profile_dir=alpha, health_probe=None, use_cache=False)plats = profile_platforms_from_multiplexer(live.runtime, "default")