The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(pty): pin the 1:1 marker discard when the disconnect cancels mid-close
Tekniumc905fad2418d
diff --git a/tests/hermes_cli/test_pty_keepalive_ws.py b/tests/hermes_cli/test_pty_keepalive_ws.pyindex cd4d6fa2454..2e239811e98 100644--- a/tests/hermes_cli/test_pty_keepalive_ws.py+++ b/tests/hermes_cli/test_pty_keepalive_ws.py@@ -225,6 +225,37 @@ async def test_legacy_channel_connect_pops_marker_on_disconnect(pty_keepalive_haassert "LEGACY63553" not in markers+async def test_legacy_marker_dropped_when_cancel_lands_mid_close(pty_keepalive_harness, monkeypatch):+ """The disconnect closes the bridge in a worker thread; cancelling the handler while that close is still+ running must not skip the marker discard."""+ import threading+ import time+ from starlette.testclient import TestClient++ close_started = threading.Event()++ def slow_close(self):+ close_started.set()+ time.sleep(0.5) # still running when the client context exits and cancels the handler+ self.alive = False++ monkeypatch.setattr(FakeBridge, "close", slow_close)+ markers = _pty_marker_dict()+ markers.clear()+ client = TestClient(web_server.app)+ with client.websocket_connect("/api/pty?channel=LEGACYCANCEL") as ws:+ ws.send_bytes(b"hi")+ assert "LEGACYCANCEL" in markers+ ws.close()+ assert close_started.wait(5) # teardown is inside bridge.close ...+ # ... and leaving the client context cancelled the handler there.+ deadline = time.monotonic() + 5.0+ while "LEGACYCANCEL" in markers and time.monotonic() < deadline:+ time.sleep(0.01)+ assert "LEGACYCANCEL" not in markers++@pytest.mark.asyncioasync def test_fresh_start_pops_stale_marker_and_reregisters_child_path(pty_keepalive_harness, tmp_path, monkeypatch