diff --git a/src/crewai/task.py b/src/crewai/task.py index 9e98adb1a5..8b1a05ca0b 100644 --- a/src/crewai/task.py +++ b/src/crewai/task.py @@ -213,8 +213,8 @@ def _execute_core( tools: Optional[List[Any]], ) -> TaskOutput: """Run the core execution logic of the task.""" - self.agent = agent agent = agent or self.agent + self.agent = agent if not agent: raise Exception( f"The task '{self.description}' has no agent assigned, therefore it can't be executed directly and should be executed in a Crew using a specific process that support that, like hierarchical."