Skip to content

fix: expose Gemini Live API client override#5987

Open
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/live-api-client-property
Open

fix: expose Gemini Live API client override#5987
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/live-api-client-property

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Fixes #5862.

Summary

Gemini already exposes api_client as a public override point for normal model calls, but Live API connections still use the private _live_api_client property. That makes regional Vertex AI Live setups depend on overriding a private member even though this is a real extension point.

This adds a public live_api_client property, documents the override pattern, and switches connect() to use it. The old _live_api_client property remains as a compatibility alias. Existing subclasses that already override _live_api_client are still honored by the default live_api_client implementation.

Validation

python -m py_compile src\google\adk\models\google_llm.py tests\unittests\models\test_google_llm.py
python -m pytest tests\unittests\models\test_google_llm.py -q -k "live_api_client or connect_with_custom_headers or connect_without_custom_headers"
python -m pytest tests\unittests\models\test_google_llm.py -q -k "live_api_client or live_api_version or speech_config"
python -m pyink --check src\google\adk\models\google_llm.py tests\unittests\models\test_google_llm.py
git diff --check upstream/main...HEAD

Note: my local environment initially had google-genai==1.65.0; this branch was tested after installing the repository-required google-genai>=2.4,<3.

@adk-bot adk-bot added the live [Component] This issue is related to live, voice and video chat label Jun 5, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Jun 5, 2026

Response from ADK Triaging Agent

Hello @he-yufeng, thank you for creating this PR!

Your PR looks great and has successfully been labeled with live. Thank you for associating the issue (#5862), writing thorough unit tests, and including the verification commands in the "Validation" section.

To fully satisfy the Contribution Guidelines, could you please update your description to include a quick summary or console output of the passed pytest results?

This will help reviewers understand that all tests are passing successfully and speed up the review process. Thanks!

@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Jun 5, 2026

I have completed a thorough, read-only analysis of Pull Request #5987 to verify its value, architecture alignment, and code quality.

The full structured evaluation has been compiled into the following premium artifact:

  • 📂 analysis_results.md

Key Highlights of Findings

  • Objective: Exposes live_api_client as a public, documented property on the Gemini class to let developers override the Client utilized by Live API connections (resolving issue #5862).
  • Backward Compatibility: Excellent. The design dynamically detects legacy _live_api_client overrides (via MRO inspections), ensuring existing subclass integrations continue to function properly.
  • Test Quality: Implements robust, high-fidelity mock assertions inside test_google_llm.py covering all scenarios (private aliases, public overrides, and legacy private overrides).
  • Recommendation: Approve. The changes are elegant, clean, and follow the exact patterns established elsewhere in the ADK repository.

Summary of Work Done

  • Compliance Gate: Checked GitHub status checks and verified that the Google CLA (cla/google) is successfully signed by the contributor.
  • Diff Acquisition: Fetched and analyzed the raw line-by-line diff of PR fix: expose Gemini Live API client override #5987.
  • Codebase Verification: Inspected the baseline implementation of google_llm.py in the active workspace to confirm the presence of the gap and verify architectural consistency.
  • Reporting: Generated a detailed analysis report formatted as a persistent markdown artifact.

@rohityan rohityan self-assigned this Jun 5, 2026
@rohityan
Copy link
Copy Markdown
Collaborator

rohityan commented Jun 5, 2026

/adk-pr-analyze

@he-yufeng he-yufeng force-pushed the fix/live-api-client-property branch from 933060c to f286222 Compare June 6, 2026 17:21
@he-yufeng
Copy link
Copy Markdown
Contributor Author

Updated the branch to cover the mTLS Gemini endpoint in the Live API base URL test as well. This should satisfy the hardcoded googleapis.com check for the changed test file.

Validated locally:

  • python -m py_compile src/google/adk/models/google_llm.py tests/unittests/models/test_google_llm.py
  • uv run pyink --check src/google/adk/models/google_llm.py tests/unittests/models/test_google_llm.py
  • .venv\Scripts\python -m pytest -q tests\unittests\models\test_google_llm.py -k "live_api_client_uses_api_version_from_google_base_url or live_api_client_properties or api_client_uses_api_version_from_google_base_url" --basetemp .tmp\pytest-5987-models -p no:cacheprovider

Focused model tests passed: 4 passed, 61 deselected.

@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Jun 6, 2026

I have completed a thorough, read-only analysis of Pull Request #5987 to verify its value, architectural alignment, backward compatibility, and code quality.

The full structured evaluation has been compiled into the following premium artifact:

📂 analysis_results.md

Key Highlights

  • Core Objective: Exposes live_api_client as a public, documented property on the Gemini class to let developers cleanly customize the underlying connection client for the Live API (resolving issue #5862).
  • Design & Backward Compatibility: Outstanding. The author implemented a flawless backward compatibility bridge that checks the class hierarchy's MRO to recognize legacy private overrides (_live_api_client), guaranteeing zero breaking changes or runtime regressions.
  • Testing Rigor: Comprehensive new parameterizations and unit tests added to test_google_llm.py ensuring client configurations, regular endpoints, secure mTLS connections, and subclass overrides behave cleanly and securely.
  • Recommendation: Approve.

Summary of Work Done

  • Information Retrieval: Acquired complete PR metadata and tracked down the original issue context for Make _live_api_client a public, documented override point (like api_client) #5862.
  • Analysis & Verification: Fetched and assessed the full, line-by-line PR diff, comparing it against the baseline codebase structures within the active workspace.
  • Reporting: Synthesized detailed findings, style checklist items, and architectural assessments into a persistent markdown artifact.

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.

Make _live_api_client a public, documented override point (like api_client)

3 participants