Skip to content

feat: add Gemini 3.1 Flash Live support for run_live()#5076

Open
imazizongit wants to merge 1 commit intogoogle:mainfrom
imazizongit:feat/gemini-3.1-flash-live-support
Open

feat: add Gemini 3.1 Flash Live support for run_live()#5076
imazizongit wants to merge 1 commit intogoogle:mainfrom
imazizongit:feat/gemini-3.1-flash-live-support

Conversation

@imazizongit
Copy link
Copy Markdown

@imazizongit imazizongit commented Mar 31, 2026

Summary

Adds support for gemini-3.1-flash-live-preview in ADK's bidi-streaming pipeline (run_live()). Without these changes, 3.1 models fail with WebSocket errors (1007/1008/1011).

Changes

Backward-compatible upgrades (all models)

  1. send_realtime(): Use audio= instead of deprecated media= parameter in send_realtime_input(). The media= parameter produces the deprecated mediaChunks wire format which 3.1 rejects. The audio= parameter works on all models.

  2. send_content(): Use send_tool_response() instead of session.send(LiveClientToolResponse(...)) for function responses. This is the current non-deprecated API.

3.1-specific changes (conditional on model_version)

  1. send_content() text routing: 3.1 models reject LiveClientContent for mid-conversation text with error 1007: Request contains an invalid argument. Text content is routed through send_realtime_input(text=...) when model_version contains "3.1". Uses the existing self._model_version field.

  2. connect() history_config: 3.1 models require HistoryConfig(initial_history_in_client_content=True) for session history. Injected in Gemini.connect() when model contains "3.1" and not already set by the caller.

Not included (model limitations, documented in #5075)

The following LiveConnectConfig fields are not supported by 3.1 models and will cause connection errors:

  • enable_affective_dialog (1011 Internal error)
  • context_window_compression (1007 Invalid argument)
  • proactivity (1007 Unknown name)

These are model API limitations, not ADK bugs. Users should not set these fields when using 3.1 models.

Testing

  • Tested in production with real PSTN phone calls via Telnyx
  • Verified tool calling (collect_caller_data, end_conversation) works on 3.1
  • Verified audio input/output works with native audio bidi-streaming
  • Backward compatible: 2.5 models continue to work without changes

Related

@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 31, 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.

Changes:
1. send_realtime(): use audio= instead of deprecated media= (all models)
2. send_content(): use send_tool_response() for function responses (all models)
3. send_content(): route text via send_realtime_input for 3.1 models
4. connect(): inject history_config for 3.1 models

Changes 1-2 are backward-compatible API upgrades (removing deprecated usage).
Changes 3-4 are conditional on model version containing '3.1'.

Tested in production with real phone calls on gemini-3.1-flash-live-preview.

Note: 3.1 models do not support enable_affective_dialog,
context_window_compression, or proactivity config fields.
These are documented in issue google#5075 as model limitations.

Fixes google#5018
@imazizongit imazizongit force-pushed the feat/gemini-3.1-flash-live-support branch from e591734 to b6cc92a Compare March 31, 2026 03:53
@adk-bot adk-bot added the live [Component] This issue is related to live, voice and video chat label Mar 31, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Mar 31, 2026

Response from ADK Triaging Agent

Hello @imazizongit, thank you for your contribution!

Before we can merge this pull request, you'll need to sign the Contributor License Agreement (CLA). Please check the pull request status checks for a link to the CLA.

Thanks!

@rohityan rohityan self-assigned this Apr 1, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADK does not support the newest gemini-3.1-flash-live-preview

3 participants