Streaming tool support for ADK Agent #2985
Replies: 2 comments
-
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The Hello! It looks like you're running into an issue with serializing This error typically occurs when the framework attempts to serialize the generator object itself, rather than consuming the values it yields. This was a recognized problem in earlier versions of the ADK and was specifically addressed in the v1.11.0 release [2]. To fix this, please update your pip install --upgrade google-adk For your reference, a streaming tool should be defined as an import asyncio
from typing import AsyncGenerator
async def my_streaming_tool() -> AsyncGenerator[str, None]:
"""A tool that streams back a sequence of strings."""
for i in range(5):
yield f"This is chunk {i}\n"
await asyncio.sleep(1) Upgrading should resolve the serialization error and allow the ADK to correctly handle the streaming output from your tool. [1] https://google.github.io/adk-docs/streaming/streaming-tools/ |
Beta Was this translation helpful? Give feedback.
-
Google ADK version I am using is 1.14.1 I am adding the code below, import asyncio async def monitor_stock_price(stock_symbol: str) -> AsyncGenerator[str, None]: await asyncio.sleep(2) root_agent = Agent( |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to make use of a tool which can stream the responses back to the agent. But always getting stuck with the Async generator serialisation error. I also tried using the examples given in https://google.github.io/adk-docs/streaming/streaming-tools/.
How to make it work for an ADK agent?
Beta Was this translation helpful? Give feedback.
All reactions