Skip to content

feat: support audio_stream_end for realtime input#4490

Open
lottielin wants to merge 2 commits intogoogle:mainfrom
lottielin:support-audio-stream-end
Open

feat: support audio_stream_end for realtime input#4490
lottielin wants to merge 2 commits intogoogle:mainfrom
lottielin:support-audio-stream-end

Conversation

@lottielin
Copy link

@lottielin lottielin commented Feb 14, 2026

Problem:
send_realtime method only accepted Blob (audio/video bytes), ActivityStart, and ActivityEnd. There's no mechanism to send the audioStreamEnd boolean field, which is required to flush cached audio when Voice Activity Detection (VAD) is enabled.

Solution:
This PR updates the GeminiLlmConnection, BaseLlmFlow, and LiveRequestQueue to support sending generic LiveClientRealtimeInput messages with audio_stream_end field configured to the Gemini Live API. This closes #2887.

Testing Plan

Unit Tests:

  • added unit test test_send_realtime_audiostreamend
  • all unit tests passing locally

Additional context

  • processing priority: activity_start > activity_end > audio_stream_end > blob > content
    • this is to follows the principal of control signals > data payloads, since audio_stream_end is a signal to flush the audio buffer

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lottielin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the real-time input capabilities of the system by introducing explicit support for an audio_stream_end signal. This signal is vital for scenarios where Voice Activity Detection (VAD) is active, allowing the system to flush cached audio effectively. The changes involve extending data models, updating core flow logic to process this new signal, and ensuring the LLM connection can correctly interpret and forward it to the Gemini Live API.

Highlights

  • New audio_stream_end signal: Introduced a boolean field in LiveRequest and a dedicated method send_audio_stream_end to signal the end of an audio stream, crucial for Voice Activity Detection (VAD) to flush cached audio.
  • Realtime input handling: Modified BaseLlmFlow to process the new audio_stream_end signal by wrapping it in types.LiveClientRealtimeInput and sending it to the LLM connection.
  • Expanded RealtimeInput type: Updated GeminiLlmConnection to accept types.LiveClientRealtimeInput in its RealtimeInput Union, enabling the system to recognize and handle the new signal.
  • Unit test coverage: Added a new unit test to verify the correct behavior of send_realtime when audio_stream_end is provided.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/google/adk/agents/live_request_queue.py
    • Added audio_stream_end boolean field to LiveRequest model with documentation.
    • Implemented send_audio_stream_end method to enqueue a LiveRequest with audio_stream_end set to True.
  • src/google/adk/flows/llm_flows/base_llm_flow.py
    • Modified _send_to_model to check for live_request.audio_stream_end and send it as types.LiveClientRealtimeInput.
  • src/google/adk/models/gemini_llm_connection.py
    • Expanded RealtimeInput type alias to include types.LiveClientRealtimeInput.
    • Updated send_realtime method to handle types.LiveClientRealtimeInput by forwarding audio_stream_end to the Gemini session.
    • Added a warning for unsupported unary LiveClientRealtimeInput.
  • tests/unittests/models/test_gemini_llm_connection.py
    • Added test_send_realtime_audiostreamend to verify audio_stream_end signal handling.
Activity
  • New unit test test_send_realtime_audiostreamend was added to cover the new functionality.
  • All unit tests are reported as passing locally by the author.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added the live [Component] This issue is related to live, voice and video chat label Feb 14, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully adds support for audio_stream_end in realtime inputs, which is crucial for VAD-enabled audio flushing. The changes are well-implemented across the LiveRequest model, BaseLlmFlow, and GeminiLlmConnection, and are accompanied by a solid unit test. My only feedback is a suggestion to improve the maintainability of documentation in the LiveRequest model to prevent inconsistencies.

@ryanaiagent ryanaiagent self-assigned this Feb 18, 2026
@ryanaiagent
Copy link
Collaborator

ryanaiagent commented Feb 18, 2026

Hi @lottielin , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you please address the comments and also update the branch to main.

@ryanaiagent ryanaiagent added the request clarification [Status] The maintainer need clarification or more information from the author label Feb 18, 2026
@lottielin lottielin force-pushed the support-audio-stream-end branch from 1153f53 to 93fdc83 Compare February 19, 2026 02:21
@lottielin
Copy link
Author

lottielin commented Feb 19, 2026

Hi @lottielin , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you please address the comments and also update the branch to main.

hi @ryanaiagent , thanks for helping with the review. I've updated the branch and addressed the AI comment.

@ryanaiagent
Copy link
Collaborator

Hi @lottielin , can you fix the mypy-diff error and also add the test case as i requested earlier.

@lottielin lottielin force-pushed the support-audio-stream-end branch 2 times, most recently from 82ced97 to 2670040 Compare February 19, 2026 05:04
@lottielin
Copy link
Author

hi @ryanaiagent i've updated the code to fix the mypy-diff error, however i don't see your comments on test case changes, do you mind reposting, thanks!

# Should not call .send function
mock_gemini_session.send.assert_not_called()


Copy link
Collaborator

@ryanaiagent ryanaiagent Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a test to cover the send_realtime with unsupported LiveClientRealtimeInput where it logs a warning.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryanaiagent added the new test case, thank you!

@lottielin lottielin force-pushed the support-audio-stream-end branch from 2670040 to 4c3e009 Compare February 19, 2026 22:44
@lottielin lottielin force-pushed the support-audio-stream-end branch from 4c3e009 to df966c6 Compare February 19, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

live [Component] This issue is related to live, voice and video chat request clarification [Status] The maintainer need clarification or more information from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support gemini audioStreamEnd for realtimeInput

3 participants

Comments