Skip to content

fix(models): Default grounding metadata for Gemini 3.1 live#6018

Merged
wukath merged 1 commit into
v1from
fix-gemini-3.1-live-grounding-metadata-v1
Jun 8, 2026
Merged

fix(models): Default grounding metadata for Gemini 3.1 live#6018
wukath merged 1 commit into
v1from
fix-gemini-3.1-live-grounding-metadata-v1

Conversation

@wukath

@wukath wukath commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Default grounding_metadata to types.GroundingMetadata() for Gemini 3.1 Flash Live connections, and support path-based model identifiers by extracting model name before checking prefixes.

@adk-bot adk-bot added the live [Component] This issue is related to live, voice and video chat label Jun 8, 2026
@adk-bot

adk-bot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Response from ADK Triaging Agent

Hello @wukath, thank you for your contribution!

We noticed that this pull request is missing a few requirements from our contribution guidelines:

  • Associated Issue: Please associate a GitHub issue with this PR. If there isn't one yet, please create one or describe the bug/feature directly within the PR description following our issue templates.
  • Testing Plan: Please add a testing plan section in your PR description detailing how the change was or can be verified.
  • Logs/Screenshots: As this is a bug fix, please provide logs or screenshots of the behavior after the fix is applied to help reviewers understand the changes.

Please update the PR description with these details. This will help our reviewers process your PR much faster. Thank you!

@adk-bot

adk-bot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

I have retrieved and completed a detailed review of Pull Request #6018, "fix(models): Default grounding metadata for Gemini 3.1 live".

The full analysis has been compiled into a high-fidelity artifact report located at pr_analysis_report_6018.md.

Summary of Findings & Work Played:

  • Core Improvements: The PR ensures that grounding_metadata on Gemini 3.1 Live connection responses defaults to an empty types.GroundingMetadata() instead of remaining None. Additionally, it patches model-name prefix matches so that path-based resource names (e.g. Vertex AI format) are correctly extracted and matched via is_gemini_3_1_flash_live.
  • Optimization Best Practice: Caches the resolved model identifier check in GeminiLlmConnection.init as self._is_gemini_3_1_flash_live to avoid redundant matching overhead on every streaming message frame.
  • Architectural & Style Alignment: Code meets high standards and unit/regression tests are beautifully local and behavior-focused (no excessive mocking of core engines). Only a minor type annotation nit is present on the cached attribute.

Please view the comprehensive report pr_analysis_report_6018.md for detailed findings. No further actions or approvals are needed to approve this PR.

@wukath wukath force-pushed the fix-gemini-3.1-live-grounding-metadata-v1 branch 2 times, most recently from f07a668 to ce97940 Compare June 8, 2026 18:13
@adk-bot

adk-bot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

I will now read the instructions for the adk-pr-analyze skill to ensure we follow the designated steps exactly.I will now run the compliance verification script to verify if the author of Pull Request #6018 has signed the Google Contributor License Agreement (CLA). This is a critical regulatory gate before any diff reading or analysis can begin.I will use the custom python tool fetch_github_pr to fetch the metadata for Pull Request #6018.I will now attempt to retrieve the PR diff using the GitHub CLI (gh). This will provide the line-by-line code changes made in this Pull Request.I will inspect the existing contents of src/google/adk/models/gemini_llm_connection.py to understand its baseline structure and see where the changes are being made.I will continue viewing the baseline file src/google/adk/models/gemini_llm_connection.py to see how the connection's message subscription / processing operates.I will run the command to retrieve the diff for src/google/adk/models/gemini_llm_connection.py specifically so we can see the exact changes without any truncation.I will run git branch -a to see if the branch for PR #6018 is already checked out or exists locally.I will check out the PR branch locally using the GitHub CLI (gh pr checkout) to inspect the modified source files directly. This will let us view the exact changes in the codebase.I will now load the modified src/google/adk/models/gemini_llm_connection.py from the checkout to inspect the changes.I will load lines 101 to 180 of src/google/adk/models/gemini_llm_connection.py on the PR branch.I will view the portion of receive in src/google/adk/models/gemini_llm_connection.py on the PR branch (lines 210 to 300).I will load lines 301 to 490 of src/google/adk/models/gemini_llm_connection.py to see the remainder of the receive method.I will now inspect the modifications in src/google/adk/utils/model_name_utils.py.I will inspect the imports of src/google/adk/utils/model_name_utils.py to check for from __future__ import annotations and any typing patterns.I will view the new tests added in tests/unittests/models/test_gemini_llm_connection.py to check their structure, assert patterns, and fixture localized nature.I will run the unit tests in both modified modules to verify that the implementation works correctly and passes all test suites.I will now create the premium analysis report as a high-fidelity markdown artifact to organize our findings for the user.I have completed my review and analysis of Pull Request #6018: "fix(models): Default grounding metadata for Gemini 3.1 live".

The complete architectural evaluation, style alignment checklist, and detailed verification findings have been saved to a high-fidelity artifact report:

👉 pr_analysis_report_6018.md

Key Takeaway for PR #6018:

  • Recommendation: Approve with Nits.
  • This PR is a high-value, systematic bug fix. Beyond correcting the defaults for Gemini 3.1 Flash Live connections, it optimizes future checks by caching model eligibility inside __init__, avoiding parsing overhead on every message chunk inside the async loop.
  • Open Decisions / Nits to address:
    • In gemini_llm_connection.py:L53, the newly cached attribute self._is_gemini_3_1_flash_live is missing an explicit type annotation. We suggest requesting the author to add it:
      self._is_gemini_3_1_flash_live: bool = model_name_utils.is_gemini_3_1_flash_live(
          model_version
      )

Turn Summary of Completed Actions:

  1. Checked out the remote PR branch fix-gemini-3.1-live-grounding-metadata-v1 locally using gh.
  2. Inspected connection and utility modules (gemini_llm_connection.py, model_name_utils.py) to verify the workspace status before and after the modification.
  3. Inspected the newly added unit tests to verify they strictly adhere to ADK's behavioral testing and localized fixture standards.
  4. Compiled and published a comprehensive evaluation artifact.

@adk-bot

adk-bot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

I have completed a comprehensive review of PR #6018: "fix(models): Default grounding metadata for Gemini 3.1 live".

The complete, high-fidelity report has been compiled and saved to the following artifact:
👉 pr_analysis_report_6018.md


Summary of Findings & Critical Regression

While the core objectives of this PR are highly justified and valuable—specifically resolving the prefix checks on path-based model identifiers and defaulting grounding_metadata on Gemini 3.1 Live connections—there is a critical regression that must be resolved before approval.

🔴 Critical Code Quality / Runtime Bug

In gemini_llm_connection.py, the author deleted the initialization of is_thought = False at the start of GeminiLlmConnection.receive:

   async def receive(self) -> AsyncGenerator[LlmResponse, None]:
     ...
     text = ''
-    is_thought = False  <-- DELETED IN PR
     tool_call_parts = []
     pending_grounding_metadata = None

Because is_thought is assigned later inside the loop scope, Python classifies it as a local variable. During the streaming frames evaluation, the line below is evaluated before assignment:

if text and current_is_thought != is_thought:

This causes static analyzers (such as Pylint, Ruff, or Pytype) to fail, and will trigger an UnboundLocalError at runtime under conditions where text is already populated.

Recommended Action

Push Back (Request Changes): Request that the author restore is_thought = False in the initialization block of receive().


Work Performed Summary

  • Successfully pulled the metadata for PR fix(models): Default grounding metadata for Gemini 3.1 live #6018 and verified the Contributor License Agreement (CLA) status (SUCCESS).
  • Fetched is_gemini_3_1_flash_live changes and corresponding connection changes.
  • Checked out and reviewed the remote changes locally on a temporary branch to verify file structures.
  • Traced static paths and uncovered a local scope variable leakage (is_thought) and its runtime failure vectors.
  • Documented analysis findings, principle checklists, and testing patterns in pr_analysis_report_6018.md.

Default grounding_metadata to types.GroundingMetadata() for Gemini 3.1 Flash Live connections, and support path-based model identifiers by extracting model name before checking prefixes.

Change-Id: I042ac5b12e9e424a19c3ead9b87c7db04affdae8
@wukath wukath force-pushed the fix-gemini-3.1-live-grounding-metadata-v1 branch from ce97940 to 2807de5 Compare June 8, 2026 18:24
@adk-bot

adk-bot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

I will read the instructions for the adk-pr-analyze skill to ensure we follow the required process for analyzing the pull request.I will run the CLA verification script for PR 6018 in read-only mode to check if the contributor has signed the Google CLA.I will use the fetch_github_pr tool to retrieve the details of PR 6018, which is the preferred method as it avoids running terminal commands that might trigger permission issues.I will call the fetch_github_pr tool with the correct parameter pr_number to get the PR details.I will locate the file gemini_llm_connection.py in our workspace to inspect its current state.I will locate the file model_id_utils.py or model_name_utils.py in the workspace.I will view the first 200 lines of src/google/adk/models/gemini_llm_connection.py to inspect the initialization of the connection and check if the cached model eligibility logic or the is_gemini_3_1_flash_live reference is present.I will retrieve the code diff of the pull request to perform a detailed line-by-line code review of the changes. I'll execute the gh pr diff command.I will check out the PR branch locally so we can view the modified source files (gemini_llm_connection.py, etc.) directly using our standard text-viewing/reading tools.I will inspect lines 35 to 110 of the newly checked-out src/google/adk/models/gemini_llm_connection.py to examine the constructor and cached attributes.I will view lines 200 to 300 of src/google/adk/models/gemini_llm_connection.py to examine the receive method.I will check the git log on this branch to understand the commit history and see if the author pushed an update recently to fix the is_thought issue.I will display the specific commit 2807de58b45d9cb645e1099448559b06cb6d3d6e using git show to inspect exactly what changes were introduced.I will run a git diff command specifically on src/google/adk/models/gemini_llm_connection.py to see exactly what changes were introduced to that file under this PR.I will inspect src/google/adk/models/gemini_llm_connection.py at the parent commit aafd97f6f0ae114b0ca772b4f5176602e3677e79 to see if is_thought was already defined or if it was omitted, resolving whether the bot's reported critical regression is accurate or a hallucination.I will run the unit tests in test_gemini_llm_connection.py to verify that the implementation is robust, correct, and passes all existing and new test cases.I will view src/google/adk/utils/model_name_utils.py to examine the baseline and changes to model name handling and extraction.I will create a comprehensive, premium Pull Request Analysis Report artifact containing our detailed findings, architectural evaluations, compliance checks, and final recommendations for PR 6018.I will switch the workspace repository back to its original baseline branch to leave the workspace in a clean state.I have completed a thorough, read-only analysis of Pull Request #6018: "fix(models): Default grounding metadata for Gemini 3.1 live".

The comprehensive, high-fidelity report has been compiled and saved to the following artifact:
👉 pr_analysis_report_6018.md


📝 Executive Summary of Findings

  1. Core Objectives (Pass):
    • Correctly establishes empty types.GroundingMetadata() fallbacks on all emitted stream responses of GeminiLlmConnection for Gemini 3.1 Flash Live connections.
    • Refactors prefix checks in is_gemini_3_1_flash_live to support path-based model identifiers (e.g. Vertex AI format) by extracting the base model name via extract_model_name prior to matching.
  2. Performance Improvements (Excellent):
    • Rather than executing string regex parsing repeatedly on every single hot async iteration frame inside the stream generator loop, the evaluation outcome is cached as self._is_gemini_3_1_flash_live in __init__.
  3. No Critical Regressions (Pass):
    • A previously reported scope issue where is_thought had been missing its default declaration block has been fully resolved of any UnboundLocalError vectors in the author's latest commit by adding is_thought = False to the start of the receive async generator.
  4. Principle & Style Alignment Nits (Nit):
    • In src/google/adk/models/gemini_llm_connection.py, the newly cached state attribute lacks an explicit type annotation. We suggest requesting the author to add it:
      self._is_gemini_3_1_flash_live: bool = model_name_utils.is_gemini_3_1_flash_live(
          model_version
      )

🎯 Final Recommendation: Approve with Nits

The code quality is outstanding, coverage of the added unit tests is excellent, and it fixes an important hurdle for Vertex AI live endpoint users.


🛠️ Work Completed Summary

  • Checked out and evaluated the PR branch fix-gemini-3.1-live-grounding-metadata-v1.
  • Analyzed connection handler and utility changes to verify codebase integrity.
  • Confirmed that the critical scoping issue was addressed by the author.
  • Generated premium artifact analysis report at pr_analysis_report_6018.md.
  • Restored active workspace repository state back to main.

@wukath wukath merged commit fafafb3 into v1 Jun 8, 2026
10 checks passed
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.

2 participants