Fix issue #2791: Task tools now combine with agent tools instead of overriding them

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-05-08 19:05:55 +00:00
parent cb1a98cabf
commit e128125428
5 changed files with 963 additions and 1995 deletions

View File

@@ -321,8 +321,11 @@ class Task(BaseModel):
@model_validator(mode="after")
def check_tools(self):
"""Check if the tools are set."""
if not self.tools and self.agent and self.agent.tools:
self.tools.extend(self.agent.tools)
if self.agent and self.agent.tools:
existing_tool_names = {tool.name for tool in self.tools}
for tool in self.agent.tools:
if tool.name not in existing_tool_names:
self.tools.append(tool)
return self
@model_validator(mode="after")