Skip to content

fix/issue-3955 : add text modality to live streaming#382

Open
morganroux wants to merge 5 commits intogoogle:mainfrom
morganroux:fix/issue-3955
Open

fix/issue-3955 : add text modality to live streaming#382
morganroux wants to merge 5 commits intogoogle:mainfrom
morganroux:fix/issue-3955

Conversation

@morganroux
Copy link
Copy Markdown

@morganroux morganroux commented Feb 14, 2026

Fix: add text modality to live streaming

Summary

Implements a new Live Streaming toggle feature that enables real-time text communication through WebSocket connections as an alternative to Server-Sent Events (SSE). This feature provides users with toggle control between SSE and Live Streaming modes for text-based chat.
Messages are handled the same way as SSE events to provide a uniform user experience

Motivation

This PR adresses adk-python issue #3955 / adk-web issues/383 by adding support for bidirectional text streaming using WebSockets, complementing the existing audio and video live streaming capabilities. This enables more efficient real-time text communication compared to the existing SSE implementation.

Changes

🎨 UI/UX Changes

  • New toggle control in chat toolbar for Live Streaming (chat.component.html:211-222)
  • Toggle is conditionally rendered based on feature flag
  • Disabled when Token Streaming (SSE) is active to ensure mutual exclusivity
  • Added internationalization label: liveStreamingLabel: 'Live Streaming'

🏗️ Architecture Changes

  • Unified streaming service: Extended StreamChatService to support audio/video/text streaming
  • WebSocket integration: Connects to /run_live endpoint with appName, userId, and sessionId parameters
  • Mutual exclusivity: SSE and Live Streaming cannot be active simultaneously

🔧 Core Implementation

  1. Feature Flag Service (feature-flag.service.ts:78-80)

    • Added isLiveStreamingEnabled() method (enabled by default)
  2. Stream Chat Service (stream-chat.service.ts)

    • startTextStreaming(): Establishes WebSocket connection
    • stopTextStreaming(): Cleanly closes connection
    • sendTextMessage(): Sends messages in LiveRequest format
    • getTextMessages(): Returns observable stream for components
    • Filters out audio blob messages to prevent processing issues
  3. Chat Component (chat.component.ts)

    • toggleLiveStreaming(): Manages connection lifecycle and message subscriptions
    • Modified sendMessage(): Early return for Live Streaming mode (lines 532-541)
    • Updated toggleSse(): Disables Live Streaming when SSE is enabled
    • Reuses existing event processing pipeline (combineTextParts, processPart, etc.)

🧪 Testing

  • Added comprehensive unit tests in chat.component.spec.ts (138 new test lines)
  • Tests cover:
    • Toggle behavior (enabling/disabling)
    • Mutual exclusivity with SSE
    • WebSocket connection management
    • Message sending via WebSocket
    • Session restart warnings for bidirectional usage
  • Added mock services for MockFeatureFlagService and MockStreamChatService
  • Added tests in stream-chat.service.spec.ts for text streaming methods

How to manually test this fix

  • follow https://google.github.io/adk-docs/streaming/streaming-tools/
  • change agent model to gemini-2.5-flash-native-audio-preview-12-2025
  • open adk-web
  • enable "Live streaming" toggle
  • type "Monitor Google stock" in the input and press enter
  • audio answer is played, and other events are displayed as text
  • refresh the page, the message history is the same as if the audio modality was used

closes: #383
closes: google/adk-python#3955

@google-cla
Copy link
Copy Markdown

google-cla bot commented Feb 14, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@morganroux morganroux marked this pull request as ready for review February 14, 2026 16:24
@morganroux
Copy link
Copy Markdown
Author

Hello, I've fixed the existing issue in what I feel is the best approach, but I'm very much open to any suggestions or improvements on this PR.

@Robbilie
Copy link
Copy Markdown

probably has some overlap with my PR :)
#381

@Robbilie
Copy link
Copy Markdown

the text streaming of responses can still be toggled even if live streaming, that has nothing to do with the transport

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming tools example in the documentation does not work Streaming tools example in the documentation does not work

2 participants