Enhance Flow Listener Logic and Agent Imports

- Updated the Flow class to track fired OR listeners, ensuring that multi-source OR listeners only trigger once during execution. This prevents redundant executions and improves flow efficiency.
- Cleared fired OR listeners during cyclic flow resets to allow re-execution in new cycles.
- Modified the Agent class imports to include Coroutine from collections.abc, enhancing type handling for asynchronous operations.

These changes improve the control and performance of flow execution in CrewAI, ensuring more predictable behavior in complex scenarios.
This commit is contained in:
lorenzejay
2026-01-15 16:12:13 -08:00
parent 7f7b5094cc
commit 64052745b7
3 changed files with 43 additions and 6 deletions

View File

@@ -1202,8 +1202,9 @@ def test_complex_and_or_branching():
)
assert execution_order.index("branch_2b") > min_branch_1_index
# Final should be last and after both 2a and 2b
assert execution_order[-1] == "final"
# Final should be after both 2a and 2b
# Note: final may not be absolutely last due to independent branches (like branch_1c)
# that don't contribute to the final result path with sequential listener execution
assert execution_order.index("final") > execution_order.index("branch_2a")
assert execution_order.index("final") > execution_order.index("branch_2b")