Skip to content

fix(flow): preserve parallel producers feeding or_ - #7272

Open
lprnmns wants to merge 1 commit into
crewAIInc:mainfrom
lprnmns:fix/or-listener-producer-cancellation
Open

fix(flow): preserve parallel producers feeding or_#7272
lprnmns wants to merge 1 commit into
crewAIInc:mainfrom
lprnmns:fix/or-listener-producer-cancellation

Conversation

@lprnmns

@lprnmns lprnmns commented Sep 4, 2026

Copy link
Copy Markdown

Related issue

Fixes #7183

Summary

  • remove the listener-racing path that treated producers referenced by a downstream or_() as a first-wins race
  • execute every independently triggered producer and keep _fired_or_listeners responsible for firing the downstream join once
  • add a regression test covering a fast and a slow producer feeding the same or_() join

Verification

  • Regression test fails on main: the slow producer is absent from completed
  • uv run pytest lib/crewai/tests/test_flow.py::test_or_listener_does_not_cancel_parallel_producers -q -o 'addopts=--tb=short --timeout=60 --block-network --import-mode=importlib' — 1 passed
  • uv run pytest lib/crewai/tests/test_flow.py -x -q — 83 passed
  • uv run pytest lib/crewai/tests/ -x -q — 5283 passed, 44 skipped
  • uv run pre-commit run --files lib/crewai/src/crewai/flow/runtime/__init__.py lib/crewai/tests/test_flow.py — Ruff, format, and mypy passed

Additional context

The public or_() behavior remains unchanged: the downstream listener fires once. The fix only stops that condition from cancelling independently triggered producer work.

AI disclosure: this contribution was developed with OpenAI Codex assistance. Per the contribution policy, it must carry the llm-generated label.

@lprnmns

lprnmns commented Sep 4, 2026

Copy link
Copy Markdown
Author

AI assistance is disclosed in the PR body. I attempted to apply the required llm-generated label during creation and through the labels API, but GitHub returned 403 because fork contributors do not have label permission. A repository collaborator will need to apply the label.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 2e1e8ef9-a67d-4a71-b018-be8627563d0e

📥 Commits

Reviewing files that changed from the base of the PR and between c00e322 and 9c62c0b.

📒 Files selected for processing (2)
  • lib/crewai/src/crewai/flow/runtime/__init__.py
  • lib/crewai/tests/test_flow.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The flow runtime removes first-wins cancellation for multi-event or_() listeners. Triggered listeners now run through asyncio.gather. A regression test verifies that parallel producers complete and the OR listener fires once.

Changes

OR listener execution

Layer / File(s) Summary
Parallel listener execution and regression coverage
lib/crewai/src/crewai/flow/runtime/__init__.py, lib/crewai/tests/test_flow.py
_execute_listeners now runs all triggered listeners in parallel without racing-group cancellation. The test verifies that both asynchronous producer branches complete and the or_() listener fires exactly once.

Suggested reviewers: lucasgomide

Merge Risk: ⚪ Minimal · up to 9c62c

OR joins now preserve independently triggered producer work while still firing the downstream join once. Regression coverage confirms both branches complete and the join remains deduplicated, with no remaining merge-readiness risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preserving parallel producers that feed an or_() listener.
Description check ✅ Passed The description includes the related issue, solution summary, verification results, additional context, and required test and quality-check information.
Linked Issues check ✅ Passed The implementation addresses issue [#7183] by removing producer cancellation, preserving completion of independently triggered branches, retaining downstream or_() deduplication, and adding the requ…
Out of Scope Changes check ✅ Passed The changes are limited to the listener execution fix and its regression test. No unrelated code or scope expansion is present.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] or_() join cancels parallel listener branches that should complete

1 participant