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

Problem with retrive live conversation using sessions.

Open NikitaZemtsov opened this issue 1 year ago • 8 comments

Trying to restart live conversation using sessions. By user_id I get the last and only session. When initializing run_live I pass the session. The session is not empty, it contains events. I ask for the data that the conversation was about and the model doesn't know anything about it. I also decided to try to specify initial data in state and the model doesn't know anything about them either. Questions:

  1. What could be the problem? I went through the call chain and it looks like everything is being sent.
  2. I can't see in events session the data I send to the model, only its responses. Is this how it should be? Do I need to implement their addition myself? Through session_service.append_event?

Image

Image

NikitaZemtsov avatar May 16 '25 16:05 NikitaZemtsov

Trying to restart live conversation using sessions. By user_id I get the last and only session. When initializing run_live I pass the session. The session is not empty, it contains events. I ask for the data that the conversation was about and the model doesn't know anything about it. I also decided to try to specify initial data in state and the model doesn't know anything about them either. Questions:

  1. What could be the problem? I went through the call chain and it looks like everything is being sent.
  2. I can't see in events session the data I send to the model, only its responses. Is this how it should be? Do I need to implement their addition myself? Through session_service.append_event?

Image

Image

UPDATE:

Identified a very strange behavior of the system. Repeatability 10/10.

  1. I start an audio conversation
  2. Saying control information.
  3. I delete the runner instance. 4)Re-create the runner with the same session.
  4. I ask control questions through audio conversation system replies that it does not have such information.
  5. I send text type data (empty message) dee img.
  6. The system starts answering control questions correctly.

Added sending an empty message each time a runner is created with an existing session. The system works and pulls data from the session, but reacts to the empty message and starts responding to it.

Image

NikitaZemtsov avatar May 17 '25 20:05 NikitaZemtsov

Trying to restart live conversation using sessions. By user_id I get the last and only session. When initializing run_live I pass the session. The session is not empty, it contains events. I ask for the data that the conversation was about and the model doesn't know anything about it. I also decided to try to specify initial data in state and the model doesn't know anything about them either. Questions:

  1. What could be the problem? I went through the call chain and it looks like everything is being sent.
  2. I can't see in events session the data I send to the model, only its responses. Is this how it should be? Do I need to implement their addition myself? Through session_service.append_event?

Image Image

UPDATE:

Identified a very strange behavior of the system. Repeatability 10/10.

  1. I start an audio conversation
  2. Saying control information.
  3. I delete the runner instance. 4)Re-create the runner with the same session.
  4. I ask control questions through audio conversation system replies that it does not have such information.
  5. I send text type data (empty message) dee img.
  6. The system starts answering control questions correctly.

Added sending an empty message each time a runner is created with an existing session. The system works and pulls data from the session, but reacts to the empty message and starts responding to it.

Image

I found the problem, but I don't understand on which side it should be solved on the google_adk or gemini side. I am using the code from the documentation example. https://google.github.io/adk-docs/streaming/custom-streaming/#client_to_agent_messagingwebsocket-live_request_queue:~:text=elif%20mime_type%20%3D%3D,%3Dmime_type))) It does not work correctly with sessions and audio send with method "send_realtime". When a session with events is resumed, the "send_history" method is called and it checks turn_complete=contents[-1].role == 'user' The method description says, "The model will respond if the last content is from user, otherwise it will wait for new user input before responding." In the session history, the last event is the model response (role='model') and gemini waits for content with the role='user'. But since I am using audio and sending data via "send_realtime" method in which data is sent as Blob and not content and it has no role attribute, the model does not initialize the history and waits for any content from user.
When I send a message through as a content object using method "send_content" (role='user', turn_complete=True), the model initializes the session history and starts responding correctly. But the trick with an empty event (role="user") does not work correctly, because the model perceives the last message from the user as question and tries to respond to it. Although I expect the response to be to an audio stream.

Image

NikitaZemtsov avatar May 18 '25 12:05 NikitaZemtsov

@NikitaZemtsov thank you for reporting the issue with detailed information and analysis. @hangfei & @DeanChensj could you please help to a look ? whether we should save the blob sent to LLM in a event content with role as user by default ?

seanzhou1023 avatar May 19 '25 20:05 seanzhou1023

@NikitaZemtsov thanks for the detailed research. The session for live is not fully working and we are adding support for it at the meantime.

Could you share what you want to achieve more specifically?

hangfei avatar May 28 '25 20:05 hangfei

@hangfei Yes, sessions for audio (Live) work only if output_audio_transcription and input_audio_transcription are enabled. Since when reusing a session, all inline_data is filtered.

I am implementing a dual chat audio and text. The idea is to switch from audio to text and see the audio chat in text form, that is, continue communication in the same context without switching the model. At the moment, this is achieved using output_audio_transcription and input_audio_transcription. And sending a text and audio stream at the same time. And when switching to text chat, the audio stream does not disappear, it just does not play. In this implementation, sessions work fine, except for the bug described above.

I encountered one unpleasant moment when using input_audio_transcription. The user's text comes in pieces, and each piece is recorded as a separate event. The model handles this normally, but for RAG, you have to collect these pieces into sentences. It would be cool if after all the pieces the whole text was sent, as it is implemented in the model. Also now this parts stored in session_service as separated events but models answer as one event.

NikitaZemtsov avatar Jun 02 '25 22:06 NikitaZemtsov

I have similar problem: https://github.com/google/adk-python/issues/1675

XinyueZ avatar Jun 26 '25 19:06 XinyueZ

Hi @NikitaZemtsov and thanks to everyone who participated in this thread!

We're currently doing some housekeeping on our issue tracker. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this issue has been resolved in a newer version. To help us keep our backlog focused on current issues, we are closing this as stale.

If you're still facing this problem, could you please update to the very latest version of the library and confirm the issue still exists? If it does, please comment here, and we will be happy to reopen this issue and investigate further.

Thanks for your contribution and understanding!

jwiejulie avatar Aug 14 '25 20:08 jwiejulie

Hi @NikitaZemtsov and thanks to everyone who participated in this thread.

We're currently doing some housekeeping on our issue tracker. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this issue has been resolved in a newer version. To help us keep our backlog focused on current issues, we are closing this as stale.

If you're still facing this problem, could you please update to the very latest version of the library and confirm the issue still exists? If it does, please comment here, and we will be happy to reopen this issue and investigate further.

Thanks for your contribution and understanding!

surajksharma07 avatar Oct 07 '25 08:10 surajksharma07