-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
bot triaged[Bot] This issue is triaged by ADK bot[Bot] This issue is triaged by ADK botcore[Component] This issue is related to the core interface and implementation[Component] This issue is related to the core interface and implementation
Description
** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.
Describe the bug
from google.adk import Agent
from google.adk.tools import FunctionTool
tools: list[FunctionTool] = ...
Agent(..., tools=tools)
Will fail to type check (like in Pylance) like:
Argument of type "list[FunctionTool]" cannot be assigned to parameter "tools" of type "list[ToolUnion]" in function "__init__"
"list[FunctionTool]" is not assignable to "list[ToolUnion]"
Type parameter "_T@list" is invariant, but "FunctionTool" is not the same as "ToolUnion"
Consider switching from "list" to "Sequence" which is covariantPylance[reportArgumentType](https://github.com/microsoft/pylance-release/blob/main/docs/diagnostics/reportArgumentType.md)
Because ADK had class Agent like:
class Agent(BaseModel)
...
tools: list[ToolUnion] = Field(default_factory=list)
and list[T]
seems to be invariant on T in Python.
Expected behavior
Passing a list[FunctionTool]
should type check.
Screenshots
Additional context
Metadata
Metadata
Assignees
Labels
bot triaged[Bot] This issue is triaged by ADK bot[Bot] This issue is triaged by ADK botcore[Component] This issue is related to the core interface and implementation[Component] This issue is related to the core interface and implementation