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

Text Messages Don't Create Session Events in Live Streaming Mode

Open frankfarzan opened this issue 1 year ago • 6 comments

Summary

In live streaming mode, text messages sent via live_request_queue.send_content() do not create Session events with role="user", while audio messages sent via live_request_queue.send_realtime() do create these events.

Current Behavior

  • live_request_queue.send_content(): Bypasses Session event creation and goes directly to LLM via send_content()
  • live_request_queue.send_realtime(): Creates Session events with role="user" through model transcription feature

Expected Behavior

Both send_content() and send_realtime() should consistently create Session events with role="user" for proper conversation history tracking.

Root Cause

Text content sent via send_content() in live mode bypasses the normal _append_new_message_to_session() pathway used in non-live mode. Audio blobs work because the LLM model's transcription feature generates LlmResponse objects with role="user" content that flow back through the system.

Impact

  • Inconsistent Session history between text and audio inputs
  • Missing user messages in Session events when using send_content()
  • Potential issues with conversation tracking and debugging

Code Location

  • LiveRequestQueue.send_content() and send_realtime() in src/google/adk/agents/live_request_queue.py
  • BaseLlmFlow._send_to_model() in src/google/adk/flows/llm_flows/base_llm_flow.py
  • Runner._append_new_message_to_session() in src/google/adk/runners.py
  • GeminiLlmConnection.receive() transcription handling in src/google/adk/models/gemini_llm_connection.py

frankfarzan avatar Jul 18 '25 20:07 frankfarzan

I assumed that's the way it was intended. After all, it makes no sense to add the audio user to the event, it just clutters the event and takes up extra space. Text messages can be added separately, controlling what you add.

It would be cool to have a flag to delete agent audio data. Since they clog up the database a lot and don't carry any meaningful load. I made a wrapper for myself over DatabaseSessionService and delete agent audio data. It saves a lot of space.

NikitaZemtsov avatar Jul 21 '25 21:07 NikitaZemtsov

@NikitaZemtsov This issue is about sending text content, e.g.:

content = Content(
    role="user", parts=[Part.from_text(text="Hello")]
)
live_request_queue.send_content(content=content)

This is not added to the Session. Audio blobs work fine as they are transcribed and added to Session as expected.

frankfarzan avatar Jul 22 '25 04:07 frankfarzan

Hi @frankfarzan ,

First of all, my apologies — I wasn't aware that this issue had already been reported. I ended up creating a duplicate issue with a possible fix. The changes I made resolved the problem for me: user input messages are now being saved correctly. You can check the details in #2175.

As for @NikitaZemtsov — regarding the audio blobs from the agent, I also duplicated that issue. However, the fix is quite straightforward: you just need to filter out inline_data in each append method of the session service (though I'm not sure if this applies to the Vertex session service). More details are in #2172.

ac-machache avatar Jul 27 '25 11:07 ac-machache

@hangfei FYI

DeanChensj avatar Jul 31 '25 17:07 DeanChensj

We are working on the support.

hangfei avatar Aug 15 '25 19:08 hangfei

This is fixed now. Please check latest release.

hangfei avatar Nov 08 '25 03:11 hangfei