From eb62ed7a6a5b56d23cf49a55bb3c95e73b389fc3 Mon Sep 17 00:00:00 2001 From: Greyson LaLonde Date: Mon, 2 Feb 2026 10:07:56 -0500 Subject: [PATCH] fix: resolve race condition in guardrail event emission test --- lib/crewai/tests/test_task_guardrails.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/crewai/tests/test_task_guardrails.py b/lib/crewai/tests/test_task_guardrails.py index 986441343..814de2f8f 100644 --- a/lib/crewai/tests/test_task_guardrails.py +++ b/lib/crewai/tests/test_task_guardrails.py @@ -249,6 +249,8 @@ def test_guardrail_emits_events(sample_agent): result = task.execute_sync(agent=sample_agent) + crewai_event_bus.flush(timeout=10.0) + with condition: success = condition.wait_for( lambda: len(started_guardrail) >= 2 and len(completed_guardrail) >= 2, @@ -267,6 +269,8 @@ def test_guardrail_emits_events(sample_agent): task.execute_sync(agent=sample_agent) + crewai_event_bus.flush(timeout=10.0) + with condition: success = condition.wait_for( lambda: len(started_guardrail) >= 3 and len(completed_guardrail) >= 3,