From c09f226b9ec70d93bca2a3d57072f98abafbeeb7 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Mon, 8 Jun 2026 17:37:00 -0700 Subject: [PATCH] Synchronize async goal cancellation test --- sdk/python/tests/test_app_server_goal_turns.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sdk/python/tests/test_app_server_goal_turns.py b/sdk/python/tests/test_app_server_goal_turns.py index b2b8bfd12e..901e8ab870 100644 --- a/sdk/python/tests/test_app_server_goal_turns.py +++ b/sdk/python/tests/test_app_server_goal_turns.py @@ -800,7 +800,12 @@ def test_async_goal_start_cancellation_interrupts_work_and_releases_routing(tmp_ async with AsyncCodex(config=harness.app_server_config()) as codex: thread = await codex.thread_start() startup = asyncio.create_task(thread.start_goal("Cancel this goal during startup")) - await asyncio.sleep(0) + + deadline = time.monotonic() + 5 + while not codex._client._sync._router._goal_operations: + if time.monotonic() >= deadline: + raise AssertionError("goal startup did not register routing") + await asyncio.sleep(0.01) # Keep the event loop occupied until model work starts so the # worker result cannot reach start_goal before cancellation.