diff --git a/tests/orchestrator/test_child_done_events.py b/tests/orchestrator/test_child_done_events.py index 560def575..87933391c 100644 --- a/tests/orchestrator/test_child_done_events.py +++ b/tests/orchestrator/test_child_done_events.py @@ -224,7 +224,8 @@ async def _consume() -> None: consumer_task = asyncio.create_task(_consume()) # Wait for: first turn (instant) + 50ms timeout + second turn (instant). - await asyncio.sleep(0.15) + # Use generous sleep to avoid flakiness on slow CI runners. + await asyncio.sleep(0.3) # Close to unblock idle. handle.close() diff --git a/tests/orchestrator/test_subagent_events.py b/tests/orchestrator/test_subagent_events.py index 266d7ee93..71b91e678 100644 --- a/tests/orchestrator/test_subagent_events.py +++ b/tests/orchestrator/test_subagent_events.py @@ -564,6 +564,12 @@ async def test_nested_subagents_create_recursive_toolparts() -> None: # But actually, the parent consumer subscribes with descendants scope to parent_id, # and the spawn event for child would be published on parent_id by the agent runtime. # Let's publish on parent_id. + # Wait for parent consumer to initialize before publishing depth=2 event. + for _ in range(50): + if parent_id in integration._contexts: + break + await asyncio.sleep(0.01) + await asyncio.sleep(0.05) await _publish_spawn_event( session_pool, parent_id, child_id, source_name="worker2", depth=2 )