Vertex AI Search Grounding Metadata not included in Gemini 3.5 response
🔴 Required Information
Please ensure all items in this section are completed to allow for efficient triaging. Requests without complete information may be rejected / deprioritized. If an item is not applicable to you - please mark it as N/A
Describe the Bug:
As Gemini 2.5 is getting deprecated, we are forced to move to Gemini 3.5. Our application strictly requires that grounding metadata are included in the model response. We use VertexAiSearchTool (data store that indexes text files in a bucket). We infer the URL of the internal documentation from the object URI. Furthermore, we have safeguards in place that reject a response that has no grounding chunks.
Steps to Reproduce: Please provide a numbered list of steps to reproduce the behavior:
- Use VertexAISearchTool.
- Use Gemini 3.5 Flash in the EU region.
- Attempt to extract grounding metadata during an after_model_callback.
Expected Behavior: A clear and concise description of what you expected to happen.
Observed Behavior: What actually happened? Include error messages or crash stack traces here.
Environment Details:
- ADK Library Version: 2.5
- Desktop OS: macOS + Linux
- Python Version (python -V): >=3.13
Model Information:
- Are you using LiteLLM: No
- Which model is being used: gemini-3.5-flash, gemini-3.5-flash-lite
🟡 Optional Information
Providing this information greatly speeds up the resolution process.
Regression: N/A
Logs: N/A
Screenshots / Video: N/A
Additional Context: N/A
Minimal Reproduction Code: Instantiate an agent with the appropriate tool
How often has this issue occurred?:
- Always (100%)
Taking a look at this. Planning to build a repro against VertexAiSearchTool + gemini-3.5-flash and compare grounding metadata behavior against the pre-3.5 path to pin down expected vs. actual. Will share findings here and put together a fix if it turns out to be something fixable on the ADK side.
Hi @tionichm, could you please share a reproducible code example? This will help us better understand and investigate the issue.
Hi @tionichm, could you please share a reproducible code example? This will help us better understand and investigate the issue. Hello! Thanks for getting back to me.
@sidgupta04, it's a good thing you asked me to dive a bit deeper into the issue.I did some work on my end to try and isolate the case where the grounding metadata is omitted from the model response.
It seems to be specifically caused when a ToolConfig is specified.
import os
from google.adk.agents import Agent
from google.adk.agents.callback_context import CallbackContext
from google.adk.models import Gemini
from google.adk.models.llm_response import LlmResponse
from google.adk.tools.vertex_ai_search_tool import VertexAiSearchTool
PROJECT = "<MY_GCP_PROJECT>"
LOCATION = "eu"
DATASTORE_NAME = "<MY_DATASTORE_NAME>"
os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "TRUE"
os.environ["GOOGLE_CLOUD_PROJECT"] = PROJECT
os.environ["GOOGLE_CLOUD_LOCATION"] = LOCATION
def _after_agent_callback(
callback_context: CallbackContext,
llm_response: LlmResponse,
) -> LlmResponse | None:
if not (ground := llm_response.grounding_metadata):
raise RuntimeError("No grounding metadata found in agent response.")
if not ground.grounding_chunks:
raise RuntimeError("No grounding chunks found in agent response.")
if not ground.grounding_supports:
raise RuntimeError("No grounding supports found in agent response.")
return llm_response
root_agent = Agent(
name="faulty",
model=Gemini(model="gemini-3.5-flash"),
description="A bot that fetches docs for Vertex Search Data Store.",
static_instruction="Based on a query, fetch docs from Vertex Search Data Store and answer the query.",
tools=[
VertexAiSearchTool(
data_store_id=f"projects/{PROJECT}/locations/{LOCATION}/collections/default_collection/dataStores/{DATASTORE_NAME}",
max_results=5,
)
],
# NOTE: Uncomment this to cause the agent call to fail due to missing grounding metadata in the response.
#
# generate_content_config=GenerateContentConfig(
# tool_config=ToolConfig(function_calling_config=FunctionCallingConfig(mode=FunctionCallingConfigMode.ANY)),
# ),
after_model_callback=_after_agent_callback,
)
@sanketpatil06 Hey I'm working on this, could you assign it to me. I have fix in progress, thanks!
Hi @tionichm
Quick follow-up, I've been able to reproduce a version of this against the live API using google_search as a stand-in (I don't have a Vertex AI Search data store set up to test the exact tool you're using). What I'm seeing with google_search is more severe than what you described: with the conflicting tool_config set, the API isn't just omitting grounding metadata. It's returning zero candidates entirely (empty response), while still billing several thousand tokens for the attempt.
Before I generalize this to VertexAiSearchTool specifically, I want to check against what you actually saw, since it's possible the two tools behave differently here. A few questions:
- When your
after_model_callbackraised the "No grounding metadata found" error, wasllm_response.contentpopulated with real text, or was it empty? - Did you notice any warning-level log output around the time of the failure (even if it looked unrelated)?
- If you still have logs from that run, do you know roughly how many tokens were billed, or whether
candidatescame back empty vs. populated?
This would help confirm whether we're looking at the same failure mode or two related-but-distinct ones.
I can confirm that llm.content is None on my end.
Hi @sidgupta04 and @tionichm an internal team will now be looking into this. Thanks for bringing this up!