The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui): keep the observed parent for the Windows slash-worker watchdog
kshitijk4poor5b719d98e739
diff --git a/tests/tui_gateway/test_slash_worker_watchdog.py b/tests/tui_gateway/test_slash_worker_watchdog.pyindex 0854afa01b3..fead9d4cd2a 100644--- a/tests/tui_gateway/test_slash_worker_watchdog.py+++ b/tests/tui_gateway/test_slash_worker_watchdog.py@@ -68,6 +68,7 @@ def test_main_arms_watchdog_for_spawn_parent_before_cli_startup(monkeypatch):raise AssertionError("spawn parent PID must come from argv")monkeypatch.setattr(slash_worker.os, "getppid", unexpected_getppid)+ monkeypatch.setattr(sys, "platform", "linux")monkeypatch.setattr(sys,"argv",@@ -88,3 +89,21 @@ def test_main_arms_watchdog_for_spawn_parent_before_cli_startup(monkeypatch):("runtime",),("cli", "session-1"),]+++def test_windows_watchdog_keeps_observed_parent_over_spawn_pid(monkeypatch):+ # A venv python.exe redirector sits between the gateway and this interpreter on+ # Windows, so the gateway PID never equals os.getppid() there; arming on it+ # would make the watchdog kill a healthy worker on its first poll.+ armed = []+ monkeypatch.setitem(sys.modules, "cli", types.SimpleNamespace(HermesCLI=lambda **kw: types.SimpleNamespace()))+ monkeypatch.setattr(slash_worker, "_start_parent_death_watchdog", armed.append)+ monkeypatch.setattr(slash_worker, "_prepare_slash_worker_runtime", lambda: None)+ monkeypatch.setattr(slash_worker.os, "getppid", lambda: 777)+ monkeypatch.setattr(sys, "platform", "win32")+ monkeypatch.setattr(sys, "argv", ["slash_worker", "--session-key", "s", "--parent-pid", "424242"])+ monkeypatch.setattr(sys, "stdin", io.StringIO(""))++ slash_worker.main()++ assert armed == [777]diff --git a/tui_gateway/slash_worker.py b/tui_gateway/slash_worker.pyindex 54a87638f70..81cf621aaa9 100644--- a/tui_gateway/slash_worker.py+++ b/tui_gateway/slash_worker.py@@ -155,7 +155,11 @@ def main():os.environ["HERMES_INTERACTIVE"] = "1"# The gateway passes its PID at spawn so a fast exit cannot make this child# mistake a subreaper for its original parent before the watchdog starts.- orig_ppid = args.parent_pid or os.getppid()+ # The watchdog compares the kernel's live PPID against it, so a reused PID+ # can never pass for the parent. Windows never reparents, and a venv+ # python.exe redirector makes the launcher (not the gateway) our direct+ # parent there, so keep the observed PPID or the worker would exit at once.+ orig_ppid = os.getppid() if sys.platform == "win32" else (args.parent_pid or os.getppid())_start_parent_death_watchdog(orig_ppid)_prepare_slash_worker_runtime()