adk-docs icon indicating copy to clipboard operation
adk-docs copied to clipboard

Streaming Tools tutorial from the official guide fails.

Open haren-bh opened this issue 1 year ago • 5 comments

Bug Desrciption Streaming Tools tutorial in the official guide (https://google.github.io/adk-docs/streaming/streaming-tools/) is failing.

Steps To Reproduce

  1. Run the code mentioned in https://google.github.io/adk-docs/streaming/streaming-tools/
  2. It will fail with following error, 2025-09-19 11:48:08,750 - ERROR - adk_web_server.py:1076 - Error in event_generator: Failed to parse the parameter return_value: AsyncGenerator[str, NoneType] of function get_menu for automatic function calling. Automatic function calling works best with simpler function signature schema, consider manually parsing your function declaration for function get_menu. Traceback (most recent call last): File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/cli/adk_web_server.py", line 1066, in event_generator async for event in agen: ...<7 lines>... yield f"data: {sse_event}\n\n" File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/runners.py", line 314, in run_async async for event in agen: yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/runners.py", line 310, in _run_with_trace async for event in agen: yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/runners.py", line 354, in _exec_with_plugin async for event in agen: ...<8 lines>... yield (modified_event if modified_event else event) File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/runners.py", line 304, in execute async for event in agen: yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 248, in run_async async for event in agen: yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 238, in _run_with_trace async for event in agen: yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/agents/llm_agent.py", line 288, in _run_async_impl async for event in agen: self.__maybe_save_output_to_state(event) yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 401, in run_async async for event in agen: last_event = event yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 447, in _run_one_step_async async for event in agen: ...<3 lines>... yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 539, in _postprocess_async async for event in agen: yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 667, in _postprocess_handle_function_calls_async async for event in agen: yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 248, in run_async async for event in agen: yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 238, in _run_with_trace async for event in agen: yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/agents/llm_agent.py", line 288, in _run_async_impl async for event in agen: self.__maybe_save_output_to_state(event) yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 401, in run_async async for event in agen: last_event = event yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 420, in _run_one_step_async async for event in agen: yield event File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 487, in _preprocess_async await tool.process_llm_request( tool_context=tool_context, llm_request=llm_request ) File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/tools/base_tool.py", line 129, in process_llm_request llm_request.append_tools([self])

File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/models/llm_request.py", line 102, in append_tools declaration = tool._get_declaration() File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/tools/function_tool.py", line 87, in _get_declaration build_function_declaration( ~~~~~~~~~~~~~~~~~~~~~~~~~~^ func=self.func, ^^^^^^^^^^^^^^^ ...<3 lines>... variant=self._api_variant, ^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/tools/_automatic_function_calling_util.py", line 235, in build_function_declaration from_function_with_options(func, variant) ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^ File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/tools/_automatic_function_calling_util.py", line 382, in from_function_with_options _function_parameter_parse_util._parse_schema_from_parameter( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ variant, ^^^^^^^^ return_value, ^^^^^^^^^^^^^ func.name, ^^^^^^^^^^^^^^ ) ^ File "/Users/bharen/venv/adkpython/lib/python3.13/site-packages/google/adk/tools/_function_parameter_parse_util.py", line 310, in _parse_schema_from_parameter raise ValueError( ...<4 lines>... ) ValueError: Failed to parse the parameter return_value: AsyncGenerator[str, NoneType] of function get_menu for automatic function calling. Automatic function calling works best with simpler function signature schema, consider manually parsing your function declaration for function get_menu.

Expected behavior Streaming works

Desktop (please complete the following information):

  • OS: Mac
  • Python version(python -V):3.13.3
  • ADK version(pip show google-adk):1.14.0

Model Information:

  • Which model is being used(e.g. gemini-2.5-pro): Gemini 2.5 pro

Additional context I checked adk/tools/_function_parameter_parse_util.py and it seems that if the Tool has return type of AsyncGenerator, it will return the above error. I have not checked the history but this could be deprecation (in which case, the tutorial should be removed) or regression.

haren-bh avatar Sep 19 '25 06:09 haren-bh

@hangfei I see that this issue was marked as closed but I am able to repro this on the current latest version: 1.17.0. Should this issue be reopened?

samagana avatar Nov 03 '25 17:11 samagana

For some reason, for me it works fine with the ai-studio model but not when using the vertex-ai variant:

✅ gemini-2.5-flash-native-audio-preview-09-2025

tools_dict={'test': <google.adk.tools.function_tool.FunctionTool object at 0x1119246e0>

💥 gemini-live-2.5-flash-preview-native-audio-09-2025

.venv/lib/python3.13/site-packages/google/adk/tools/_function_parameter_parse_util.py", line 325, in _parse_schema_from_parameter
    raise ValueError(
    ...<4 lines>...
    )
ValueError: Failed to parse the parameter return_value: AsyncGenerator[str, NoneType]

Same code, I just flipped the GOOGLE_GENAI_USE_VERTEXAI env variable.

m-guesnon-pvotal avatar Nov 07 '25 02:11 m-guesnon-pvotal

This issue is still present in 1.18.0 version:

ValueError: Failed to parse the parameter return_value: AsyncGenerator[str, NoneType] of function send_message_stream for automatic function calling. Automatic function calling works best with simpler function signature schema, consider manually parsing your function declaration for function send_message_stream.

bugthedebugger avatar Nov 17 '25 10:11 bugthedebugger

I have the same error; is there a workaround or fix ?

alvarossl avatar Dec 12 '25 16:12 alvarossl

This issue is present in all versions from 1.14.0 - 1.20.0. Is there a reason it's been moved from adk-python to adk-docs since it is a bug not just a docs issue. And a reason for closing as complete?

dvmht avatar Dec 16 '25 11:12 dvmht