This fixes issue #4137 where task outputs were lost when a Crew executed
a mix of synchronous and asynchronous tasks. The bug was caused by
_process_async_tasks and _aprocess_async_tasks returning a new list,
which then replaced the existing task_outputs list instead of extending it.
Changes:
- Changed task_outputs = self._process_async_tasks(...) to
task_outputs.extend(self._process_async_tasks(...)) in _execute_tasks
- Changed task_outputs = await self._aprocess_async_tasks(...) to
task_outputs.extend(await self._aprocess_async_tasks(...)) in _aexecute_tasks
- Applied the same fix to _handle_conditional_task and _ahandle_conditional_task
Added tests:
- test_sync_task_outputs_preserved_when_mixing_sync_async_tasks
- test_sync_task_outputs_preserved_when_crew_ends_with_async_task
- test_sync_multiple_sync_tasks_before_async_all_preserved
- TestMixedSyncAsyncTaskOutputs class with async variants
Co-Authored-By: João <joao@crewai.com>