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

Restoring a saved session from the database for a Bidi streaming Agent doesn't work

Open sumitg opened this issue 1 year ago • 5 comments

I have a regular text based agent that has RAG as a tool. I have recently added Bidi streaming to provide voice capabilities and leverage most of the same agent code.

We store the session data in postgres using the DatabaseSessionService provided in the adk. This works fine for the text based agent but for the voice agent we get an error if we try to reload/resume the session.

We are using websockets for the audio interaction with live-api.

Error is | +-+---------------- 1 ---------------- api-1 | | Traceback (most recent call last): api-1 | | File "/usr/local/lib/python3.11/site-packages/google/genai/live.py", line 1046, in connect api-1 | | yield AsyncSession(api_client=self._api_client, websocket=ws) api-1 | | File "/usr/local/lib/python3.11/site-packages/google/adk/models/google_llm.py", line 221, in connect api-1 | | yield GeminiLlmConnection(live_session) api-1 | | File "/usr/local/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 105, in run_live api-1 | | trace_send_data(invocation_context, event_id, llm_request.contents) api-1 | | File "/usr/local/lib/python3.11/site-packages/google/adk/telemetry.py", line 156, in trace_send_data api-1 | | json.dumps([ api-1 | | File "/usr/local/lib/python3.11/json/__init__.py", line 231, in dumps api-1 | | return _default_encoder.encode(obj) api-1 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | | File "/usr/local/lib/python3.11/json/encoder.py", line 200, in encode api-1 | | chunks = self.iterencode(o, _one_shot=True) api-1 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | | File "/usr/local/lib/python3.11/json/encoder.py", line 258, in iterencode api-1 | | return _iterencode(o, 0) api-1 | | ^^^^^^^^^^^^^^^^^ api-1 | | File "/usr/local/lib/python3.11/json/encoder.py", line 180, in default api-1 | | raise TypeError(f'Object of type {o.__class__.__name__} ' api-1 | | TypeError: Object of type bytes is not JSON serializable api-1

To Reproduce Steps to reproduce the behavior:

  1. Create a basic bidi streaming agent using websockets
  2. construct a database session from the databasesessionservice instead of inmemory
  3. start the voice interaction and then leave the page or session
  4. resume session or start interaction again and see the error

Expected behavior The session resumes

Desktop (please complete the following information):

  • OS: MacOS
  • Python version(python -V): 3.11
  • ADK version(pip show google-adk): 1.2.1

sumitg avatar Jun 11 '25 17:06 sumitg

any updates on this?

sumitg avatar Jun 29 '25 12:06 sumitg

This is not supported yet.

hangfei avatar Jul 02 '25 16:07 hangfei

So for voice we should only use an in memory store?

sumitg avatar Jul 02 '25 16:07 sumitg

Any ETA on this one?

sjpritchard avatar Aug 19 '25 00:08 sjpritchard

This is supported now. Please give it a try.

hangfei avatar Nov 03 '25 23:11 hangfei