Skip to content

The agent that grows with you

test(tools): wait for the daemon-owned completion follow-up after the finite CLI exits

teknium123036d1180fd
diff --git a/tests/tools/test_completed_process_results.py b/tests/tools/test_completed_process_results.py
index d0614a452be..777751596f1 100644
--- a/tests/tools/test_completed_process_results.py
+++ b/tests/tools/test_completed_process_results.py
@@ -9,6 +9,7 @@ import subprocess
import sys
import textwrap
import threading
+import time
REPO_ROOT = Path(__file__).resolve().parents[2]
@@ -140,6 +141,12 @@ def test_headless_terminal_result_survives_cli_exit(tmp_path, request):
f"base_url={url!r}, toolsets='terminal', max_turns=3, ignore_rules=True)",
], cwd=tmp_path, env=env, stdin=subprocess.DEVNULL,
capture_output=True, text=True, encoding="utf-8", timeout=60)
+ # The canonical CLI is a finite client: it exits on its turn's terminal event while
+ # the daemon that owns the child keeps its watcher. The owned completion is admitted
+ # there as a follow-up turn, so the model must stay reachable until it arrives.
+ deadline = time.monotonic() + 30
+ while not follow_ups and time.monotonic() < deadline:
+ time.sleep(0.1)
finally:
release.touch()
server.shutdown()
@@ -150,8 +157,8 @@ def test_headless_terminal_result_survives_cli_exit(tmp_path, request):
assert len(observed) == 1, (observed, producer.stdout, producer.stderr)
process_id = observed[0]["session_id"]
assert observed[0].get("notify_on_complete") is True, observed
- # The owned notify_on_complete completion resumes in-process as a follow-up turn
- # (nested quiet-notify resume), carrying the child's real output to the model.
+ # The owned notify_on_complete completion resumes as ONE follow-up turn on the owning
+ # daemon session, carrying the child's real output and exit code to the model.
assert len(follow_ups) == 1, follow_ups
assert process_id in follow_ups[0]
assert "SYNTHETIC_REVIEW_COMPLETE" in follow_ups[0]