Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/crewai/src/crewai/utilities/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def _create_stream_chunk(
content=event.chunk,
chunk_type=chunk_type,
task_index=current_task_info["index"],
task_name=current_task_info["name"],
task_id=current_task_info["id"],
task_name=event.task_name or current_task_info["name"],
task_id=event.task_id or current_task_info["id"],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent task_index when event has different task info

The task_index is always sourced from current_task_info, while task_name and task_id now preferentially come from the event. If an event's task_id/task_name differs from current_task_info, the resulting StreamChunk will have task_index pointing to a different task than task_id/task_name. Before this change, all three fields came from the same source and were guaranteed consistent. Consumers of StreamChunk may expect these fields to reference the same task.

Fix in Cursor Fix in Web

agent_role=event.agent_role or current_task_info["agent_role"],
agent_id=event.agent_id or current_task_info["agent_id"],
tool_call=tool_call_chunk,
Expand Down