Skip to content
Closed
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
9 changes: 9 additions & 0 deletions src/crewai/crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,15 @@ def copy(self):
cloned_agents = [agent.copy() for agent in self.agents]
cloned_tasks = [task.copy(cloned_agents) for task in self.tasks]

for cloned_task in cloned_tasks:
cloned_task.context = [
next(
(reference for reference in cloned_tasks if reference.key == context_task.key),
None
)
for context_task in cloned_task.context
] if cloned_task.context else None

copied_data = self.model_dump(exclude=exclude)
copied_data = {k: v for k, v in copied_data.items() if v is not None}

Expand Down