Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

fix: resolve race condition in guardrail event emission test

Greyson LaLonde6a8483fcb610
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,