Skip to content

The agent that grows with you

fix(gateway): preserve settled host identity across restart

Hermes Agent8bde3a72e860
diff --git a/gateway/run_shutdown.py b/gateway/run_shutdown.py
index 98cfc51906f..738a37670e6 100644
--- a/gateway/run_shutdown.py
+++ b/gateway/run_shutdown.py
@@ -1396,14 +1396,19 @@ class GatewayShutdownMixin:
on_default = home.resolve() == get_default_hermes_root().resolve()
except Exception:
on_default = False
+ # ``resolve_multiplex_mode`` settles the default-on/unset decision before
+ # restart. Carry that runtime identity instead of re-reading raw config:
+ # ``None`` is the normal pre-resolution value for a named launcher.
+ from agent.secret_scope import is_multiplex_active
+ settled_multiplex = is_multiplex_active()
multiplex = False
- if not on_default:
+ if not on_default and not settled_multiplex:
try:
from gateway.config import load_gateway_config
multiplex = bool(load_gateway_config().multiplex_profiles)
except Exception:
multiplex = False
- if on_default or multiplex:
+ if on_default or settled_multiplex or multiplex:
watcher_env = host_gateway_child_env()
else:
watcher_env = served_profile_child_env(
diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py
index 0ac2d5615e6..93f8c70fb71 100644
--- a/hermes_cli/gateway.py
+++ b/hermes_cli/gateway.py
@@ -996,6 +996,9 @@ def _restart_argv_is_host_gateway(argv: list[str]) -> bool:
if any(part.startswith("--profile=") and not part.endswith("=default") for part in argv):
return False
try:
+ from agent.secret_scope import is_multiplex_active
+ if is_multiplex_active():
+ return True
from hermes_constants import get_default_hermes_root, get_hermes_home
return get_hermes_home().resolve() == get_default_hermes_root().resolve()
except Exception: