crewAI
crewAI copied to clipboard
[BUG] After attempting to use SerperDevTool, SerperDevTool and default MyCustomTool fail pydantic validation
Description
I receive Agent/Tool validation errors whenever I try to use SerperDevTool or the default MyCustomTool, after attempting to use SerperDevTool the first time. MyCustomTool works fine beforehand, and fails afterwards. The crew runs fine if I remove the tools completely, either commenting out the tools param or providing an empty array [].
I've repeated this multiple times with new crews created via crewai create crew x, and I ensured I'm using the latest via pip install -U crewai
It appears some form of caching is occurring and causing tool errors to persist
Steps to Reproduce
- Create new crew project via
crewai create crew projectx - In crew.py uncomment the lines to import
MyCustomTooland the researchertoolsline to include it for the agent crewai runand verify success- change the import to
from crewai_tools import SerperDevTooland reference the tool in the agent's tools crewai runand see errors- Revert changes and restore
MyCustomToolsetup - re-run, observe continued failures
Expected behavior
- SerperDevTool imports as an agent tool and runs successfully
- Other tools are not impacted upon validation failures of one tool
Screenshots/Code snippets
pydantic_core._pydantic_core.ValidationError: 1 validation error for Agent tools.0 Input should be a valid dictionary or instance of BaseTool [type=model_type, >input_value=SerperDevTool(name='Searc...lts=10, save_file=False), input_type=SerperDevTool] For further information visit https://errors.pydantic.dev/2.9/v/model_type An error occurred while running the crew: Command '['uv', 'run', 'run_crew']' returned non-zero exit status 1.
...
from crewai_tools import SerperDevTool
search_tool = SerperDevTool()
...
CrewBase
class SearchCrew():
"""Search crew"""
@agent
def researcher(self) -> Agent:
return Agent(
llm=ollama_llm,
config=self.agents_config['researcher'],
verbose=True,
tools=[search_tool],
)
Operating System
Other (specify in additional context)
Python Version
3.12
crewAI Version
0.79.0
crewAI Tools Version
0.79.0
Virtual Environment
Conda
Evidence
base ❯ crewai run Running the Crew Traceback (most recent call last): File "/Users/.../project/.venv/bin/run_crew", line 8, in
sys.exit(run()) ^^^^^ File "/Users/.../project/src/search/main.py", line 17, in run SearchCrew().crew().kickoff(inputs=inputs) ^^^^^^^^^^^^ File "/Users/.../project/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py", line 35, in init self.map_all_task_variables() File "/Users/.../project/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py", line 145, in map_all_task_variables self._map_task_variables( File "/Users/.../project/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py", line 178, in _map_task_variables self.tasks_config[task_name]["agent"] = agentsagent_name ^^^^^^^^^^^^^^^^^^^^ File "/Users/.../project/.venv/lib/python3.12/site-packages/crewai/project/utils.py", line 7, in memoized_func cache[key] = func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/.../project/src/search/crew.py", line 40, in researcher return Agent( ^^^^^^ File "/Users/.../project/.venv/lib/python3.12/site-packages/pydantic/main.py", line 212, in init validated_self = self.pydantic_validator.validate_python(data, self_instance=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pydantic_core._pydantic_core.ValidationError: 1 validation error for Agent tools.0 Input should be a valid dictionary or instance of BaseTool [type=model_type, >input_value=SerperDevTool(name='Searc...lts=10, save_file=False), input_type=SerperDevTool] For further information visit https://errors.pydantic.dev/2.9/v/model_type An error occurred while running the crew: Command '['uv', 'run', 'run_crew']' returned non-zero exit status 1.
Possible Solution
None
Additional context
M1 macOS list needs updating: Sequoia 15.1
I see the same issue with https://python.langchain.com/docs/integrations/tools/ddg/
Exception: 1 validation error for Agent
tools.0
Input should be a valid dictionary or instance of BaseTool [type=model_type, input_value=DuckDuckGoSearchResults(a...), output_format='json'), input_type=DuckDuckGoSearchResults]
For further information visit https://errors.pydantic.dev/2.9/v/model_type
I am also having issues using LangChain tools in the CrewAI Agents. The docs say they're supposed to work seamlessly, but pydantic complains if I use one.
I'm getting the same error when using this in CrewAI.
1 validation error for Agent tools.0 Input should be a valid dictionary or instance of BaseTool [type=model_type, input_value=DuckDuckGoSearchRun(api_w...d='api', source='text')), input_type=DuckDuckGoSearchRun]
Seems the same as https://github.com/crewAIInc/crewAI/issues/1605
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.