1- from typing import Any , Final , Literal , cast
1+ from typing import Any , Final , Literal
22
3- from adk_chatkit import ChatkitRunConfig , ClientToolCallState
3+ from adk_chatkit import ClientToolCallState , issue_client_tool_call , stream_widget
44from google .adk .tools import ToolContext
55
66from ._sample_widget import render_weather_widget
@@ -50,9 +50,7 @@ async def save_fact(
5050
5151 result = {"fact_id" : confirmed .id , "status" : "saved" }
5252
53- # add_client_tool_call_to_tool_response(result, client_tool_call, tool_context)
54- chatkit_run_config = cast (ChatkitRunConfig , tool_context ._invocation_context .run_config )
55- await chatkit_run_config .context .issue_client_tool_call (client_tool_call , tool_context )
53+ await issue_client_tool_call (client_tool_call , tool_context )
5654
5755 return result
5856
@@ -75,9 +73,7 @@ async def switch_theme(theme: str, tool_context: ToolContext) -> dict[str, str]:
7573
7674 result = {"theme" : requested }
7775
78- # add_client_tool_call_to_tool_response(result, client_tool_call, tool_context)
79- chatkit_run_config = cast (ChatkitRunConfig , tool_context ._invocation_context .run_config )
80- await chatkit_run_config .context .issue_client_tool_call (client_tool_call , tool_context )
76+ await issue_client_tool_call (client_tool_call , tool_context )
8177
8278 return result
8379
@@ -131,10 +127,8 @@ async def get_weather(
131127 if observed :
132128 result ["observation_time" ] = observed
133129
134- chatkit_run_config = cast (ChatkitRunConfig , tool_context ._invocation_context .run_config )
135-
136130 try :
137- await chatkit_run_config . context . stream_widget (widget , tool_context )
131+ await stream_widget (widget , tool_context )
138132 except Exception as exc : # noqa: BLE001
139133 print ("[WeatherTool] widget stream failed" , {"error" : str (exc )})
140134 raise ValueError ("Weather data is currently unavailable for that location." ) from exc
0 commit comments