fix: async tasks receive empty context due to last_sync_output truncation#6456
fix: async tasks receive empty context due to last_sync_output truncation#6456rafaelipuente wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughModified ChangesAsync task context fix
Sequence Diagram(s)sequenceDiagram
participant Crew
participant SyncTask
participant AsyncTask
Crew->>SyncTask: execute_sync()
SyncTask-->>Crew: append output to task_outputs
Crew->>AsyncTask: aexecute_sync(context=task_outputs)
AsyncTask-->>Crew: result reflects full prior context
Related Issues: Suggested labels: bug, llm-generated Suggested reviewers: joaomdmoura 🐰 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Description
Fixes #6417.
Tasks configured with
async_execution=Truedo not receive the correct context from prior tasks. In both_execute_tasksand_aexecute_tasks, the context for async tasks was built from[last_sync_output] if last_sync_output else [], butlast_sync_outputis only populated when resuming from a skipped/conditional task inprepare_task_executionand is otherwiseNoneduring a normal run. As a result, async tasks received an empty context and could not access the outputs of previous tasks.Fix
Pass the full
task_outputslist to_get_context()for async tasks in both executors, mirroring the behavior of synchronous tasks.This complements #6415 (same code fix) by adding regression test coverage for both execution paths.
Testing
lib/crewai/tests/crew/test_async_crew.py:_aexecute_tasks): asserts the async task'scontextcontains the prior sync task's output_execute_tasks): captures the context passed toexecute_asyncand asserts it contains the prior sync task's outputmain(async task context is empty) and pass with the fix.lib/crewai/tests/crew/test_async_crew.pysuite passes (13 tests); ruff lint/format clean on changed files.(Note: authored with the assistance of an AI coding agent. Please apply the
llm-generatedlabel.)Made with Cursor