adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

[Feature Request] Add standalone native Google Search grounding sample in contributing/samples/tools/

Open Anil-Pradhan-web opened this issue 3 weeks ago • 2 comments

🔴 Required Information

Is your feature request related to a specific problem?

Currently, there is no standalone sample under contributing/samples/tools/ demonstrating how to configure and use ADK 2.0's native built-in google_search tool with a standalone Agent.

While Google Search grounding is a core capability of the Gemini ecosystem, its only references in the samples directory are nested inside Vertex AI managed_agent samples. As a result, developers exploring ADK 2.0 frequently:

  1. Try to manually wrap types.Tool(google_search=types.GoogleSearch()) inside generate_content_config instead of using the idiomatic ADK tool abstraction (tools=[google_search]).
  2. Are unsure how to access and display search citations, source URLs, and queries from event.grounding_metadata.

Describe the Solution You'd Like

Add a minimal, standalone sample under contributing/samples/tools/google_search/ (or search_grounding/) following the repository's adk-sample-creator guidelines:

  1. agent.py:
    • Exposes root_agent using Agent(tools=[google_search]).
    • Inherits the system-configured model without hardcoding a specific model string.
  2. README.md:
    • Clear overview of how server-side native grounding works in ADK 2.0.
    • Mermaid execution flow diagram.
    • Sample user queries and instructions on how to inspect event.grounding_metadata (sources, queries, and chunk citations) from the runner stream.

Impact on your work

This provides an immediate, runnable reference for anyone building research-grounded agents or multi-agent workflows with live web access in ADK 2.0.

Willingness to contribute

Yes! I have forked the repository, tested the pattern, and would be happy to submit a clean PR implementing this sample.


🟡 Recommended Information

Describe Alternatives You've Considered

  1. Manual SDK Call: Configuring generate_content_config=types.GenerateContentConfig(...) directly. However, this bypasses ADK's native built-in google_search tool design and is discouraged in idiomatic ADK agents.
  2. Custom Python Function Tool for Web Scraping: Creating custom search functions (e.g. BeautifulSoup / DuckDuckGo), but native Google Search grounding is faster, server-side, and includes official Google citation metadata.

Proposed API / Implementation

contributing/samples/tools/google_search/agent.py:

# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Native Google Search Grounding Agent with Gemini in ADK 2.0."""

from google.adk import Agent
from google.adk.tools import google_search

root_agent = Agent(
    name="search_grounding_agent",
    description=(
        "A research assistant that answers current-events and factual "
        "questions using native Google Search grounding."
    ),
    instruction="""
      You are a helpful research assistant.
      Use Google Search when the user asks questions that depend on recent,
      time-sensitive, or specialized public information.
      Synthesize a clear and concise response and cite the sources used.
    """,
    tools=[google_search],
)

README.md preview:

  • Overview of native server-side grounding.
  • Mermaid flowchart: User -> search_grounding_agent -> google_search tool -> Grounded Response.
  • Snippet on inspecting event.grounding_metadata (queries, sources, titles, URIs).

Additional Context

This sample adheres to the project's private-by-default imports, snake_case directory naming, absence of hardcoded models, and the standard standalone agent pattern (Pattern B in adk-sample-creator).

Anil-Pradhan-web avatar Nov 07 '26 03:11 Anil-Pradhan-web

Notification: The author has updated the issue description. Maintainers, please review.

adk-bot avatar Nov 14 '26 06:11 adk-bot

Hi @Anil-Pradhan-web, Thanks for bringing this and taking time to raise a PR. Your request is currently being reviewed, and we will let you know if anything further is needed. We appreciate your contribution.

sanketpatil06 avatar Nov 16 '26 11:11 sanketpatil06