Skip to content

The agent that grows with you

fix(tui): read compute-host control frames from the byte stream

ethernet04182813cfa7
diff --git a/.github/workflows/tests-os.yml b/.github/workflows/tests-os.yml
index b80b0ac3e25..0dd8812ffa6 100644
--- a/.github/workflows/tests-os.yml
+++ b/.github/workflows/tests-os.yml
@@ -168,6 +168,9 @@ jobs:
-m "platforms and not integration" \
-v --tb=short
env:
+ # These files spawn nested PowerShell trees. CPU-count parallelism
+ # starves cold child startup before the fixture's idle deadline.
+ HERMES_TEST_WORKERS: ${{ matrix.marker == 'windows' && '8' || '' }}
# Belt-and-suspenders with tests/conftest.py's env blanking: no
# test may reach a real provider API.
OPENROUTER_API_KEY: ""
diff --git a/tests/tui_gateway/test_isolated_orphan_activity.py b/tests/tui_gateway/test_isolated_orphan_activity.py
index fa130e011b5..afb46d545b2 100644
--- a/tests/tui_gateway/test_isolated_orphan_activity.py
+++ b/tests/tui_gateway/test_isolated_orphan_activity.py
@@ -29,6 +29,7 @@ def _session(sid):
attached_images=[], cols=80, source="desktop", inflight_turn=None)
[email protected]("linux", "macos", "windows")
@pytest.mark.parametrize("mode", ["fresh", "stale", "missing", "previous"])
def test_real_child_detached_turn_activity(tmp_path, monkeypatch, mode):
"""Real supervisor pipes, child admission/turn thread, bridge and orphan timer.
@@ -63,7 +64,7 @@ def test_real_child_detached_turn_activity(tmp_path, monkeypatch, mode):
time.sleep(0.02)
assert (tmp_path / "provider-started").exists(), supervisor._stderr_tail
# Give the actual child-to-parent sampler a bounded opportunity to arrive.
- deadline = time.monotonic() + 3
+ deadline = time.monotonic() + 10
while not server._ws_orphan_turn_activity_is_fresh(session) and time.monotonic() < deadline:
time.sleep(0.02)
assert supervisor.is_running()
@@ -108,7 +109,7 @@ def test_real_child_detached_turn_activity(tmp_path, monkeypatch, mode):
# Also replay a delayed sample from the previous dispatch.
server._relay_compute_host_rpc({"method": "compute_host.activity", "params": {
"session_id": sid, "turn_id": old_token, "activity_ns": time.perf_counter_ns()}})
- deadline = time.monotonic() + 3
+ deadline = time.monotonic() + 10
while "_compute_host_activity_ns" not in session and time.monotonic() < deadline:
time.sleep(0.02)
assert "_compute_host_activity_ns" in session
@@ -161,7 +162,7 @@ def _run_child(mode, directory):
self.session_id = sid
self._interrupt = threading.Event()
if mode == "previous":
- self._touch_activity("previous turn")
+ self._last_activity_ts = time.time() - 60
def get_activity_summary(self):
return build_activity_snapshot(last_activity_at=getattr(self, "_last_activity_ts", None),
@@ -183,7 +184,9 @@ def _run_child(mode, directory):
self._touch_activity("provider wait")
elif mode == "stale":
self._last_activity_ts = time.time() - 3600
- return {"final_response": "done", "interrupted": self._interrupt.is_set()}
+ return {"final_response": "done", "interrupted": self._interrupt.is_set(),
+ "messages": [{"role": "user", "content": args[0]},
+ {"role": "assistant", "content": "done"}]}
def init(sid, key, agent, history, **kwargs):
s = _session(sid)
diff --git a/tui_gateway/compute_host.py b/tui_gateway/compute_host.py
index 2b76aa5b7b4..599163901d2 100644
--- a/tui_gateway/compute_host.py
+++ b/tui_gateway/compute_host.py
@@ -484,7 +484,8 @@ def _default_workers() -> int:
def run_host(stdin: Any = None, stdout: Any = None) -> None:
os.environ["HERMES_COMPUTE_HOST_CHILD"] = "1"
- stdin = stdin or sys.stdin
+ # JSONL framing is byte-oriented; avoid text-stream read-ahead on Windows pipes.
+ stdin = stdin if stdin is not None else getattr(sys.stdin, "buffer", sys.stdin)
host = ComputeHost(stdout=stdout or sys.stdout)
shutting_down = threading.Event()