The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: deflake the Windows-faked orphan reaper and the timed-out-child relay test
teknium15c755d8ee676
diff --git a/tests/hermes_cli/test_gateway.py b/tests/hermes_cli/test_gateway.pyindex a1de78b715a..db73ae46443 100644--- a/tests/hermes_cli/test_gateway.py+++ b/tests/hermes_cli/test_gateway.py@@ -15,6 +15,19 @@ import hermes_cli.gateway as gateway_BREAKAWAY_MARKER = "_HERMES_GATEWAY_BREAKAWAY"[email protected](autouse=True)+def inert_task_scheduler_probe():+ """Tests that fake ``is_windows()`` send the reaper through ``_windows_scheduled_task_state``,+ which spawns ``pwsh`` whenever one is on PATH (GitHub's ubuntu runners ship it). On a loaded+ runner that spawn outlives its 10 s timeout and ``subprocess.run`` kills it through the test's+ globally patched ``os.kill`` — a foreign PID lands in ``killed_pids``. Tests of the probe itself+ call ``.undo()`` on this fixture to reach the real function."""+ mp = pytest.MonkeyPatch()+ mp.setattr(gateway, "_windows_scheduled_task_state", lambda name: None)+ yield mp+ mp.undo()++def _install_fake_gateway_run(monkeypatch, start_gateway):module = ModuleType("gateway.run")module.start_gateway = start_gateway@@ -1211,8 +1224,11 @@ class TestWindowsScheduledTaskSupervisorGuard:assert marked_pids == [orphan_pid]assert killed_pids == []- def test_windows_scheduled_task_running_returns_false_off_windows(self, monkeypatch):+ def test_windows_scheduled_task_running_returns_false_off_windows(+ self, monkeypatch, inert_task_scheduler_probe+ ):"""The state helper is inert on POSIX (no subprocess spawned)."""+ inert_task_scheduler_probe.undo() # exercise the real probe, not the module-wide stand-inmonkeypatch.setattr(gateway, "is_windows", lambda: False)def _boom_run(*_a, **_k):diff --git a/tests/tools/test_zombie_process_cleanup.py b/tests/tools/test_zombie_process_cleanup.pyindex d79fa89a6ee..312ce26c4bf 100644--- a/tests/tools/test_zombie_process_cleanup.py+++ b/tests/tools/test_zombie_process_cleanup.py@@ -481,6 +481,25 @@ class TestDelegationCleanup:monkeypatch.setattr(relay_runtime, "get_runtime", lambda **_kwargs: relay_host)monkeypatch.setattr("tools.delegate_tool._get_child_timeout", lambda: 0.1)+ # The parent's cap must not elapse before the worker thread has opened the child's turn, or+ # the "late result" scenario degrades into "child never started" on a loaded runner. Gate the+ # settle wait the timeout rides on (``_ChildRun.run`` waits on ``heartbeat.settled``).+ class _GatedSettle(threading.Event):+ def wait(self, timeout=None):+ child_started.wait(timeout=5)+ return super().wait(timeout)++ import tools.delegate_tool as delegate_tool++ real_start_heartbeat = delegate_tool._start_heartbeat++ def start_gated_heartbeat(*args, **kwargs):+ heartbeat = real_start_heartbeat(*args, **kwargs)+ heartbeat.settled = _GatedSettle()+ return heartbeat++ monkeypatch.setattr(delegate_tool, "_start_heartbeat", start_gated_heartbeat)+def run_conversation(**kwargs):lease = relay_runtime.SESSION_COORDINATOR.acquire_conversation(profile_key=relay_runtime.current_profile_key(),