Skip to content

The agent that grows with you

fix(gateway): keep the launching turn's identity and presence markers out of the daemon

Teknium31a7d99830a7
diff --git a/hermes_cli/gateway_runtime_start.py b/hermes_cli/gateway_runtime_start.py
index 4e9515a7605..cf9ca2ee4d3 100644
--- a/hermes_cli/gateway_runtime_start.py
+++ b/hermes_cli/gateway_runtime_start.py
@@ -19,7 +19,9 @@ DAEMON_STRIPPED_ENV = (
"HERMES_KANBAN_TASK", "HERMES_KANBAN_WORKSPACE", "HERMES_KANBAN_BRANCH", "HERMES_KANBAN_RUN_ID",
"HERMES_KANBAN_CLAIM_LOCK", "HERMES_KANBAN_CLAIM_TTL_SECONDS", "HERMES_KANBAN_GOAL_MODE",
"HERMES_KANBAN_GOAL_MAX_TURNS", "HERMES_KANBAN_DB", "HERMES_KANBAN_WORKSPACES_ROOT",
- "HERMES_KANBAN_BOARD",
+ "HERMES_KANBAN_BOARD", "HERMES_TENANT", "HERMES_SESSION_SOURCE_EXPLICIT", "HERMES_TURN_AUTHOR",
+ # Human-presence/one-shot markers: inherited, every messaging/cron turn would read as attended or -q.
+ "HERMES_INTERACTIVE", "HERMES_GATEWAY_SESSION", "HERMES_SINGLE_QUERY_SESSION",
)
@@ -51,7 +53,8 @@ def spawn_unmanaged_gateway(profile_home: Path, *, deadline: float, idle_exit: b
# Profile selection is the explicit home, not the invoking client's display
# name. Launch-only approval/context/config flags ride the launching session's frozen
# policy, not the shared daemon or every later session.
- for key in DAEMON_STRIPPED_ENV:
+ from gateway.session_context import _VAR_MAP # the launching turn's session identity, too
+ for key in (*DAEMON_STRIPPED_ENV, *_VAR_MAP):
env.pop(key, None)
remaining(deadline)
logs = home / "logs"
diff --git a/tests/hermes_cli/test_daemon_launch_env_strip.py b/tests/hermes_cli/test_daemon_launch_env_strip.py
index cf8db22fe25..5cf0b5296b7 100644
--- a/tests/hermes_cli/test_daemon_launch_env_strip.py
+++ b/tests/hermes_cli/test_daemon_launch_env_strip.py
@@ -7,8 +7,15 @@ import time
import pytest
+# Every launch-scoped value a client process may hold when it auto-starts the shared daemon
+# (SWEEP_daemon-launch-env.md): consent, Kanban worker pins, the launching turn's session identity,
+# human-presence and one-shot markers, a bot-to-bot turn author.
LEAKS = {'HERMES_ACCEPT_HOOKS': '1', 'HERMES_KANBAN_TASK': 't_1', 'HERMES_KANBAN_BOARD': 'other',
- 'HERMES_KANBAN_DB': '/x/kanban.db', 'HERMES_SESSION_SOURCE': 'kanban', 'TERMINAL_CWD': '/x'}
+ 'HERMES_KANBAN_DB': '/x/kanban.db', 'HERMES_SESSION_SOURCE': 'kanban', 'TERMINAL_CWD': '/x',
+ 'HERMES_TENANT': 'acme', 'HERMES_SESSION_SOURCE_EXPLICIT': '1', 'HERMES_TURN_AUTHOR': '{"handle":"x"}',
+ 'HERMES_INTERACTIVE': '1', 'HERMES_GATEWAY_SESSION': '1', 'HERMES_SINGLE_QUERY_SESSION': '1',
+ 'HERMES_SESSION_ID': 'launching-turn', 'HERMES_SESSION_KEY': 'agent:main:tui:x',
+ 'HERMES_SESSION_PLATFORM': 'tui', 'HERMES_SESSION_CHAT_ID': 'c1', 'HERMES_CRON_SESSION': '1'}
@pytest.mark.platforms("linux")