fix: force AUDIO modality for native-audio models in run_live#5734
Open
hiteshtanejaa wants to merge 1 commit into
Open
fix: force AUDIO modality for native-audio models in run_live#5734hiteshtanejaa wants to merge 1 commit into
hiteshtanejaa wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue: #4206
Closes: #4206
Solution:
While the issue suggests fixing this in adk_web_server.py, this PR takes a deeper approach by fixing it in Runner.run_live() in runners.py. This is more robust because:
adk_web_server.py is just one entry point — run_live can be called directly by other code too
The fix lives closer to where the modality is actually used, protecting all callers not just the WebSocket endpoint
Testing Plan
Unit Tests:
I have added or updated unit tests for my change.
All unit tests pass locally.
Manual End-to-End (E2E) Tests:
gemini-live-2.5-flash-native-audio requires Vertex AI / allowlist access not available on standard Gemini API, so full E2E was not possible locally. The fix is validated at the unit level by directly exercising Runner.run_live with a mock native-audio agent.
Checklist
I have read the CONTRIBUTING.md document. ✅
I have performed a self-review of my own code. ✅
I have commented my code, particularly in hard-to-understand areas. ✅
I have added tests that prove my fix is effective or that my feature works. ✅
New and existing unit tests pass locally with my changes. ✅
I have manually tested my changes end-to-end. ❌
Any dependent changes have been merged and published in downstream modules. ✅
Additional context
Root cause: Runner.run_live only set a default modality when response_modalities was None, but did not validate an explicitly set TEXT modality against the model's capabilities. Native-audio models only support AUDIO, causing an API error.
What this PR does:
Detects native-audio models via canonical_model.model name check
Overrides response_modalities to ['AUDIO'] with a warning log
Auto-enables output_audio_transcription so users can read audio responses as text in the UI
Known limitation: Detection relies on the native-audio substring in the model name. A more robust long-term solution would be capability-based validation once the API exposes model modality support directly.