Skip to content

fix: prevent task output loss when mixing sync and async tasks#4139

Closed
Rakshit-gen wants to merge 2 commits into
crewAIInc:mainfrom
Rakshit-gen:fix/async-task-outputs-lost-4137
Closed

fix: prevent task output loss when mixing sync and async tasks#4139
Rakshit-gen wants to merge 2 commits into
crewAIInc:mainfrom
Rakshit-gen:fix/async-task-outputs-lost-4137

Conversation

@Rakshit-gen
Copy link
Copy Markdown

@Rakshit-gen Rakshit-gen commented Dec 20, 2025

Fixes #4137

When processing async tasks, _process_async_tasks returns a new list containing only async task outputs. The caller was replacing the existing task_outputs list instead of extending it, causing all previous sync task outputs to be silently lost.

Changed assignment (=) to extend() at all affected locations:

  • _execute_tasks() lines 1155, 1169
  • _aexecute_tasks() lines 960, 976
  • _handle_conditional_task() line 1182
  • _ahandle_conditional_task() line 990

This ensures sync task outputs accumulated before async tasks are preserved when async tasks are collected.


Note

Replaces overwriting of task_outputs with extend() when resolving async tasks to prevent loss of prior sync outputs in both sync and async execution paths, including conditional handlers.

  • Execution flow (crew.py)
    • Replace task_outputs = ..._process_async_tasks(...) with task_outputs.extend(...) in:
      • *_aexecute_tasks() and *_execute_tasks() when flushing pending async tasks mid-loop and at the end.
      • *_ahandle_conditional_task() and *_handle_conditional_task() before conditional evaluations.
    • Ensures previously accumulated sync outputs are preserved when mixing async and sync tasks and during conditional task handling.

Written by Cursor Bugbot for commit 5fcbc31. This will update automatically on new commits. Configure here.

Fixes crewAIInc#4137

When processing async tasks, `_process_async_tasks` returns a new list
containing only async task outputs. The caller was replacing the existing
`task_outputs` list instead of extending it, causing all previous sync
task outputs to be silently lost.

Changed assignment (`=`) to `extend()` at all affected locations:
- `_execute_tasks()` lines 1155, 1169
- `_aexecute_tasks()` lines 960, 976
- `_handle_conditional_task()` line 1182
- `_ahandle_conditional_task()` line 990

This ensures sync task outputs accumulated before async tasks are
preserved when async tasks are collected.
@Rakshit-gen
Copy link
Copy Markdown
Author

@gabemilani can we look into these changes?

@Findworth
Copy link
Copy Markdown

@gabemilani我们可以调查一下这些变化吗?

修复 #4137

处理异步任务时,_process_async_tasks返回一个仅包含异步任务输出的新列表。调用者错误地替换了现有task_outputs列表,而不是扩展它,导致所有先前的同步任务输出都悄无声息地丢失了。

已将所有受影响位置的分配 ( =)更改为:extend()

  • _execute_tasks()第 1155 行、1169 行
  • _aexecute_tasks()第 960、976 行
  • _handle_conditional_task()第 1182 行
  • _ahandle_conditional_task()第990行

这样可以确保在收集异步任务时,异步任务之前累积的同步任务输出能够被保留。

笔记

在解析异步任务时,替换为覆盖,task_outputsextend()防止在同步和异步执行路径(包括条件处理程序)中丢失先前的同步输出。

  • 执行流程(crew.py)

    • 替换task_outputs = ..._process_async_tasks(...)task_outputs.extend(...)in:

      • *_aexecute_tasks()*_execute_tasks()循环中途和结束时刷新待处理的异步任务。
      • *_ahandle_conditional_task()并且*_handle_conditional_task()是在条件评估之前。
    • 确保在混合异步和同步任务以及条件任务处理期间保留先前累积的同步输出。

此代码由Cursor Bugbot为提交5fcbc31编写。它会在新提交时自动更新。请在此处配置。

修复 #4137

处理异步任务时,_process_async_tasks返回一个仅包含异步任务输出的新列表。调用者错误地替换了现有task_outputs列表,而不是扩展它,导致所有先前的同步任务输出都安静无声息地丢失了。

已将所有旅行位置的分配 ( =) 更改为:extend()

  • _execute_tasks()第1155行、1169行
  • _aexecute_tasks()第960、976行
  • _handle_conditional_task()第1182章
  • _ahandle_conditional_task()第990行

这样可以保证在收集异步任务时,异步任务积累之前的同步任务输出能够被保留。

笔记

在解析异步任务时,替换为覆盖,task_outputsextend()防止在同步和异步执行路径(包括条件处理程序)中丢失先前的同步输出。

  • 执行流程(crew.py)

    • 替换task_outputs = ..._process_async_tasks(...)task_outputs.extend(...)

      • *_aexecute_tasks()*_execute_tasks()循环中途和结束时刷新待处理的异步任务。
      • *_ahandle_conditional_task()并且*_handle_conditional_task()是在条件评估之前。
    • 确保在混合异步和同步任务以及条件任务处理期间保留先前积累的同步输出。

此代码由Cursor Bugbot为提交5fcbc31编写。它会在新提交时自动更新。请在此处配置。

我也刚刚发现了这个问题,希望可以尽快合并

@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 45 days with no activity.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Task outputs lost when mixing sync and async tasks - _process_async_tasks replaces list instead of extending

3 participants