The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): a single-profile gateway start clears an inherited served_profiles list
teknium1aed011d88a0c
diff --git a/gateway/run_adapters.py b/gateway/run_adapters.pyindex 2b8b940f7f7..1246f3542fe 100644--- a/gateway/run_adapters.py+++ b/gateway/run_adapters.py@@ -829,6 +829,12 @@ class GatewayAdapterLifecycleMixin:from gateway.run import MultiplexConfigError, _multiplex_profile_homesfrom gateway.run_profile_reconcile import profile_serve_signatureif not self._multiplex_on():+ # ``write_runtime_status`` re-stamps the previous writer's record in place, so a multiplexer's+ # ``served_profiles`` would outlive it into this single-profile run and `hermes -p X ...`+ # would keep refusing (exit 78) / reporting "served" for profiles nobody serves.+ with _log_suppressed(logging.DEBUG, "could not clear served_profiles", exc_info=True):+ from gateway.status import write_runtime_status+ write_runtime_status(served_profiles=[])return 0try:from hermes_cli.profiles import get_active_profile_namediff --git a/tests/gateway/test_multiplex_adapter_registry.py b/tests/gateway/test_multiplex_adapter_registry.pyindex ca0680edbcd..1165f237b63 100644--- a/tests/gateway/test_multiplex_adapter_registry.py+++ b/tests/gateway/test_multiplex_adapter_registry.py@@ -865,6 +865,23 @@ class TestSecondaryProfileConfigHandling:assert "bad" not in runner._profile_adaptersassert "Failed to start adapters for profile 'bad'" in caplog.text+ @pytest.mark.asyncio+ async def test_single_profile_start_clears_inherited_served_profiles(self, monkeypatch, tmp_path):+ """``write_runtime_status`` re-stamps the previous writer's record in place, so a multiplexer's+ ``served_profiles`` survived into a later single-profile run and every `hermes -p X` surface+ kept treating X as served (exit 78 on start, "running via multiplexer" on status)."""+ import json+ from gateway.status import read_runtime_status++ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ (tmp_path / "gateway_state.json").write_text(json.dumps(+ {"pid": 1, "gateway_state": "stopped", "served_profiles": ["default", "coder"]}))+ runner = GatewayRunner.__new__(GatewayRunner)+ runner.config = GatewayConfig(multiplex_profiles=False)++ assert await runner._start_secondary_profile_adapters() == 0+ assert read_runtime_status(tmp_path / "gateway_state.json")["served_profiles"] == []+@pytest.mark.asyncioasync def test_multiplexer_propagates_security_config_error(self, monkeypatch):from pathlib import Path