The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): resolve the profile-aware scheduled-task name in the reaper guard
Tekniumefdd715f8ac1
diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.pyindex b0f3f6ee305..a949bb70dbb 100644--- a/hermes_cli/gateway.py+++ b/hermes_cli/gateway.py@@ -1712,8 +1712,18 @@ def _reap_unsupervised_gateway_orphans(extra_exclude: set | None = None) -> bool# before services.exe, fail-open), yet it is alive and supervised.# Querying the task state catches that case: if HermesGateway is# Running, the reaper must not touch its process tree (#86098).- if is_windows() and _windows_scheduled_task_running("HermesGateway"):- return False+ if is_windows():+ try:+ # The install-time task name is profile-aware (Hermes_Gateway /+ # Hermes_Gateway_<profile>) — never hardcode it, or the guard is+ # dormant on every standard `hermes gateway install` deployment.+ from hermes_cli.gateway_windows import get_task_name++ _task_name = get_task_name()+ except Exception:+ _task_name = "Hermes_Gateway"+ if _windows_scheduled_task_running(_task_name):+ return Falsefrom gateway.status import _pid_exists, write_planned_stop_markerdiff --git a/tests/hermes_cli/test_gateway.py b/tests/hermes_cli/test_gateway.pyindex a54d1e2d1b0..4e8cfe57479 100644--- a/tests/hermes_cli/test_gateway.py+++ b/tests/hermes_cli/test_gateway.py@@ -793,7 +793,24 @@ class TestWindowsScheduledTaskSupervisorGuard:monkeypatch.setattr(gateway, "is_windows", lambda: True)monkeypatch.setattr(gateway, "is_macos", lambda: False)monkeypatch.setattr(gateway, "supports_systemd_services", lambda: False)- monkeypatch.setattr(gateway, "_windows_scheduled_task_running", lambda name: True)+ # The guard must query the PROFILE-AWARE install-time task name from+ # gateway_windows.get_task_name(), never a hardcoded literal — a+ # hardcoded "HermesGateway" would leave the guard dormant on every+ # standard install (task name is Hermes_Gateway / Hermes_Gateway_<p>).+ import hermes_cli.gateway_windows as gateway_windows++ monkeypatch.setattr(+ gateway_windows, "get_task_name", lambda: "Hermes_Gateway_testprof"+ )+ queried = []++ def _fake_task_running(name):+ queried.append(name)+ return True++ monkeypatch.setattr(+ gateway, "_windows_scheduled_task_running", _fake_task_running+ )# Guard: if the task check were bypassed, these would be reaped.def _boom_find_gateway_pids(exclude_pids=None):@@ -807,6 +824,7 @@ class TestWindowsScheduledTaskSupervisorGuard:assert result is Falseassert killed_pids == []+ assert queried == ["Hermes_Gateway_testprof"]def test_not_running_task_still_reaps_real_orphan(self, monkeypatch):"""HermesGateway not Running (or missing) => reaper behaves as before