2323from typing import AsyncGenerator
2424from typing import Awaitable
2525from typing import Callable
26- from typing import cast
2726from typing import ClassVar
2827from typing import Dict
2928from typing import Literal
6463from .base_agent import BaseAgentState
6564from .base_agent_config import BaseAgentConfig as BaseAgentConfig
6665from .callback_context import CallbackContext
66+ from .context import Context
6767from .invocation_context import InvocationContext
6868from .llm_agent_config import LlmAgentConfig as LlmAgentConfig
6969from .readonly_context import ReadonlyContext
138138
139139async def _convert_tool_union_to_tools (
140140 tool_union : ToolUnion ,
141- ctx : ReadonlyContext ,
141+ ctx : Optional [ ReadonlyContext ] ,
142142 model : Union [str , BaseLlm ],
143143 multiple_tools : bool = False ,
144144) -> list [BaseTool ]:
@@ -152,7 +152,7 @@ async def _convert_tool_union_to_tools(
152152 from ..tools .google_search_agent_tool import create_google_search_agent
153153 from ..tools .google_search_agent_tool import GoogleSearchAgentTool
154154
155- search_tool = cast ( GoogleSearchTool , tool_union )
155+ search_tool = tool_union
156156 if search_tool .bypass_multi_tools_limit :
157157 return [GoogleSearchAgentTool (create_google_search_agent (model ))]
158158
@@ -163,7 +163,7 @@ async def _convert_tool_union_to_tools(
163163 if multiple_tools and isinstance (tool_union , VertexAiSearchTool ):
164164 from ..tools .discovery_engine_search_tool import DiscoveryEngineSearchTool
165165
166- vais_tool = cast ( VertexAiSearchTool , tool_union )
166+ vais_tool = tool_union
167167 if vais_tool .bypass_multi_tools_limit :
168168 return [
169169 DiscoveryEngineSearchTool (
@@ -927,7 +927,7 @@ def _get_available_agent_names(self) -> list[str]:
927927 """
928928 agents = []
929929
930- def collect_agents (agent ) :
930+ def collect_agents (agent : BaseAgent ) -> None :
931931 agents .append (agent .name )
932932 if hasattr (agent , 'sub_agents' ) and agent .sub_agents :
933933 for sub_agent in agent .sub_agents :
@@ -952,7 +952,7 @@ def __get_transfer_to_agent_or_none(
952952 return self .__get_agent_to_run (event .actions .transfer_to_agent )
953953 return None
954954
955- def __maybe_save_output_to_state (self , event : Event ):
955+ def __maybe_save_output_to_state (self , event : Event ) -> None :
956956 """Saves the model output to state if needed."""
957957 # skip if the event was authored by some other agent (e.g. current agent
958958 # transferred to another agent)
0 commit comments