Skip to content

The agent that grows with you

fix(gateway): anchor gateway.run's import-time home and config bridge on the process home

teknium112ca697015bb
diff --git a/gateway/run.py b/gateway/run.py
index 3f028576ee3..65cb6ee8621 100644
--- a/gateway/run.py
+++ b/gateway/run.py
@@ -1598,8 +1598,12 @@ _ensure_ssl_certs()
sys.path.insert(0, str(Path(__file__).parent.parent))
-from hermes_constants import get_hermes_home, get_hermes_home_override
-_hermes_home = get_hermes_home()
+from hermes_constants import get_hermes_home, get_hermes_home_override, get_process_hermes_home
+# The PROCESS's own home, never an import-time ContextVar: a multiplexed backend (``hermes serve``)
+# first imports this module lazily from a session's agent build, under that session's routed profile
+# override, and the import-time config bridge below would then latch the secondary's terminal.* and
+# settings into the launch process env for every later launch-profile turn.
+_hermes_home = get_process_hermes_home()
# Load ~/.hermes/.env first: user-managed env files must override stale shell exports on restart.
from hermes_cli.env_loader import load_hermes_dotenv