Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] After attempting to use SerperDevTool, SerperDevTool and default MyCustomTool fail pydantic validation #1575

Open
clayharris opened this issue Nov 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@clayharris
Copy link

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

  1. Create new crew project via crewai create crew projectx
  2. In crew.py uncomment the lines to import MyCustomTool and the researcher tools line to include it for the agent
  3. crewai run and verify success
  4. change the import to from crewai_tools import SerperDevTool and reference the tool in the agent's tools
  5. crewai run and see errors
  6. Revert changes and restore MyCustomTool setup
  7. 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

@clayharris clayharris added the bug Something isn't working label Nov 10, 2024
@danny-lowery
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants