Skip to content

fix(crew): preserve replay data after kickoff_for_each_async - #6705

Open
bardock-2393 wants to merge 1 commit into
crewAIInc:mainfrom
bardock-2393:fix/kickoff-for-each-async-replay-reset
Open

fix(crew): preserve replay data after kickoff_for_each_async#6705
bardock-2393 wants to merge 1 commit into
crewAIInc:mainfrom
bardock-2393:fix/kickoff-for-each-async-replay-reset

Conversation

@bardock-2393

Copy link
Copy Markdown

Summary

Contributes to #6704 by preserving replay data after kickoff_for_each_async() / akickoff_for_each() complete.

Both methods share run_for_each_async(). Each crew copy resets and repopulates the shared replay store as part of its own run, but run_for_each_async() then reset that same shared storage again right after gathering all the copies' results, discarding whatever they had just persisted — every call left the store empty. Removing that trailing reset is the async counterpart of the fix for #6650, which only covered the synchronous kickoff_for_each().

Because the copies run concurrently on separate threads against one shared SQLite-backed store, which copy's output survives isn't deterministic the way it is for the sequential kickoff_for_each() (guaranteed last-input-wins). This PR only fixes the unconditional wipe-to-empty; it doesn't attempt to add ordering guarantees for the concurrent case, which is a separate, harder problem.

Testing

  • uv run pytest lib/crewai/tests/test_crew.py::test_kickoff_for_each_async_persists_output_for_replay -q
  • uv run pytest lib/crewai/tests/test_crew.py -q (132 passed, 1 skipped)
  • uv run pytest lib/crewai/tests/crew/ lib/crewai/tests/skills/ -q (161 passed)
  • uv run ruff check lib/crewai/src/crewai/crews/utils.py lib/crewai/tests/test_crew.py
  • uv run ruff format --check lib/crewai/src/crewai/crews/utils.py lib/crewai/tests/test_crew.py
  • uv run mypy lib/crewai/src/crewai/crews/utils.py

run_for_each_async (shared by kickoff_for_each_async and
akickoff_for_each) reset the shared replay store immediately after
gathering results, discarding every input copy's persisted output.
Removes the trailing reset so at least one run's output survives for
replay, matching the fix already applied to the synchronous
kickoff_for_each in crewAIInc#6650.

Contributes to crewAIInc#6704
@bardock-2393

Copy link
Copy Markdown
Author

Per CONTRIBUTING.md, this should carry the llm-generated label — I don't have permission to add it myself. Could a maintainer please apply it?

@coderabbitai

coderabbitai Bot commented Jul 28, 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: Pro Plus

Run ID: 81986e9d-903a-46ce-b365-6f698a1e4582

📥 Commits

Reviewing files that changed from the base of the PR and between f15844b and 068cf6a.

📒 Files selected for processing (2)
  • lib/crewai/src/crewai/crews/utils.py
  • lib/crewai/tests/test_crew.py
💤 Files with no reviewable changes (1)
  • lib/crewai/src/crewai/crews/utils.py

📝 Walkthrough

Walkthrough

Changes

Async replay persistence

Layer / File(s) Summary
Preserve outputs and verify replay persistence
lib/crewai/src/crewai/crews/utils.py, lib/crewai/tests/test_crew.py
The async fan-out path no longer resets the task output handler before returning, and regression coverage verifies persisted outputs, expected results, execution count, and cleanup.

Suggested reviewers: joaomdmoura

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: preserving replay data after kickoff_for_each_async.
Description check ✅ Passed The description is directly about the same replay-store fix and the related async behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

1 participant