2626import timeit
2727from contextvars import ContextVar , Token
2828from dataclasses import asdict , is_dataclass
29- from typing import Any , Dict , List , Mapping , Optional
29+ from typing import Any , Dict , List , Mapping , Optional , Tuple
3030
3131from google .adk .agents .base_agent import BaseAgent
3232from google .adk .agents .callback_context import CallbackContext
6262_SKILL_LOAD_TOOL_NAMES = {"load_skill" , "load_skill_resource" }
6363
6464
65- def _mapping_from_any (value : Any ) -> dict [str , Any ]:
65+ def _mapping_from_any (value : Any ) -> Dict [str , Any ]:
6666 if value is None :
6767 return {}
6868 if isinstance (value , Mapping ):
@@ -88,7 +88,7 @@ def _mapping_from_any(value: Any) -> dict[str, Any]:
8888 return {}
8989
9090
91- def _first_text (* values : Any ) -> str | None :
91+ def _first_text (* values : Any ) -> Optional [ str ] :
9292 for value in values :
9393 if value is None :
9494 continue
@@ -98,7 +98,7 @@ def _first_text(*values: Any) -> str | None:
9898 return None
9999
100100
101- def _extract_skill_metadata (value : Any ) -> dict [str , Any ]:
101+ def _extract_skill_metadata (value : Any ) -> Dict [str , Any ]:
102102 data = _mapping_from_any (value )
103103 if not data :
104104 return {}
@@ -602,7 +602,7 @@ async def before_tool_callback(
602602 self ,
603603 * ,
604604 tool : BaseTool ,
605- tool_args : dict [str , Any ],
605+ tool_args : Dict [str , Any ],
606606 tool_context : ToolContext ,
607607 ) -> None :
608608 """
@@ -646,9 +646,9 @@ async def after_tool_callback(
646646 self ,
647647 * ,
648648 tool : BaseTool ,
649- tool_args : dict [str , Any ],
649+ tool_args : Dict [str , Any ],
650650 tool_context : ToolContext ,
651- result : dict ,
651+ result : Dict [ str , Any ] ,
652652 ) -> None :
653653 """
654654 End Tool execution - finish execute_tool span.
@@ -674,7 +674,7 @@ async def on_tool_error_callback(
674674 self ,
675675 * ,
676676 tool : BaseTool ,
677- tool_args : dict [str , Any ],
677+ tool_args : Dict [str , Any ],
678678 tool_context : ToolContext ,
679679 error : Exception ,
680680 ) -> Optional [dict ]:
@@ -832,7 +832,7 @@ def _llm_key(
832832 def _tool_key (
833833 self ,
834834 tool : BaseTool ,
835- tool_args : dict [str , Any ],
835+ tool_args : Dict [str , Any ],
836836 tool_context : ToolContext ,
837837 ) -> str :
838838 invocation_context = getattr (tool_context , "_invocation_context" , None )
@@ -848,7 +848,7 @@ def _find_active_llm_invocation(
848848 self ,
849849 callback_context : CallbackContext ,
850850 llm_request : Optional [LlmRequest ] = None ,
851- ) -> tuple [Optional [str ], Optional [LLMInvocation ]]:
851+ ) -> Tuple [Optional [str ], Optional [LLMInvocation ]]:
852852 context_request_key = _ACTIVE_LLM_REQUEST_KEY .get ()
853853 if context_request_key :
854854 invocation = self ._active_llm_invocations .get (context_request_key )
@@ -915,7 +915,7 @@ def _is_mock_placeholder(value: Any) -> bool:
915915
916916 @staticmethod
917917 def _mock_has_explicit_attrs (
918- value : Any , attr_names : tuple [str , ...]
918+ value : Any , attr_names : Tuple [str , ...]
919919 ) -> bool :
920920 value_dict = getattr (value , "__dict__" , {})
921921 return any (attr_name in value_dict for attr_name in attr_names )
0 commit comments