Fix issue #2392: Preserve ConditionalTask type in Crew.copy() and kickoff_for_each()

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-03-17 20:13:59 +00:00
parent e723e5ca3f
commit 80f0011743
2 changed files with 96 additions and 1 deletions

View File

@@ -641,7 +641,9 @@ class Task(BaseModel):
cloned_agent = get_agent_by_role(self.agent.role) if self.agent else None
cloned_tools = copy(self.tools) if self.tools else []
copied_task = Task(
# Use the actual class of the instance being copied, not just Task
task_class = self.__class__
copied_task = task_class(
**copied_data,
context=cloned_context,
agent=cloned_agent,