Skip to content

The agent that grows with you

fix(gateway): keep a terminal's systemd markers out of the unmanaged daemon

kshitijk4poorc1152fb53a1e
diff --git a/hermes_cli/gateway_runtime_start.py b/hermes_cli/gateway_runtime_start.py
index 96ed336b41e..23680c670fa 100644
--- a/hermes_cli/gateway_runtime_start.py
+++ b/hermes_cli/gateway_runtime_start.py
@@ -26,6 +26,9 @@ DAEMON_STRIPPED_ENV = (
"HERMES_INTERACTIVE", "HERMES_GATEWAY_SESSION", "HERMES_SINGLE_QUERY_SESSION",
"HERMES_EPHEMERAL_SYSTEM_PROMPT", "HERMES_PREFILL_MESSAGES_FILE", "HERMES_INFERENCE_PROVIDER",
"HERMES_ENABLE_PROJECT_PLUGINS", "HERMES_TUI_CLIENT_ENV",
+ # A terminal's shell under a systemd service (gnome-terminal-server, a user unit) carries these; the
+ # unmanaged daemon would then identify as "systemd" and maintenance would refuse it as supervised.
+ "INVOCATION_ID", "JOURNAL_STREAM",
)
diff --git a/tests/hermes_cli/test_daemon_launch_env_strip.py b/tests/hermes_cli/test_daemon_launch_env_strip.py
index 5cf0b5296b7..59bdfd7510e 100644
--- a/tests/hermes_cli/test_daemon_launch_env_strip.py
+++ b/tests/hermes_cli/test_daemon_launch_env_strip.py
@@ -9,13 +9,15 @@ 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.
+# human-presence and one-shot markers, a bot-to-bot turn author, a terminal's systemd markers.
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_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'}
+ 'HERMES_SESSION_PLATFORM': 'tui', 'HERMES_SESSION_CHAT_ID': 'c1', 'HERMES_CRON_SESSION': '1',
+ # A terminal running under a systemd service: not the daemon's own supervisor.
+ 'INVOCATION_ID': 'terminal-scope', 'JOURNAL_STREAM': '8:1'}
@pytest.mark.platforms("linux")