-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
- I confirm that I searched for my issue in https://github.com/pydantic/pydantic-ai/issues before opening this issue
Description
If my agent has any deps_type specified then tools that have no dependencies (e.g. the DuckDuckGoSearchTool from pydantic_ai.common_tools.duckduckgo) are type Tool[None] and cause the tool to complain by contravariance of the Tool type.
Shouldn't a Tool with no dependencies default to Tool[Any] to correctly use contravariant types?
I've gotten around this in my own code by just explicitly typing my tools like this:
ddgs_tool: Tool[Any] = duckduckgo_search_tool(max_results=5)to avoid the type complaints from my linter (Pylance).
Example Code
from pydantic import BaseModel
from pydantic_ai import Agent
from pydantic_ai.common_tools.duckduckgo import duckduckgo_search_tool
class AgentDeps(BaseModel):
foo: str
bar: int
agent = Agent(
deps_type=AgentDeps,
tools=[duckduckgo_search_tool()]
)Python, Pydantic AI & LLM client version
Python 3.11.13
pydantic-ai==1.0.10
openai==1.108.1