Yash kavaiya

May 20, 2025 • 3 min read

Building Intelligent Search Agents with Google's Agent Development Kit (ADK)

Building Intelligent Search Agents with Google's Agent Development Kit (ADK)

In the evolving landscape of AI application development, Google’s Agent Development Kit (ADK) stands out as a powerful framework for creating intelligent agents capable of performing complex tasks. Among its many capabilities, the ability to build search-powered agents opens up remarkable possibilities for developers looking to create contextually aware applications. Today, I’ll walk you through the process of creating a search agent using ADK, exploring the tools, implementation details, and best practices along the way.

The Power of ADK Tools: Beyond Basic LLM Interactions


Before diving into implementation, let’s understand what makes ADK such a compelling platform for agent development. At its core, ADK provides a flexible foundation for connecting large language models (LLMs) with external tools and data sources. This connection transforms passive language models into active agents capable of retrieving information, executing functions, and taking meaningful actions based on user requests.

ADK supports three primary types of tools:

  1. Function Calling Tools — Custom Python functions (99% of your tool usage)

  2. Built-in Google Tools — Pre-configured Google capabilities (search, code execution, RAG)

  3. Third-party Tools — Integration with frameworks like LangChain and Crew AI

For search agents specifically, the built-in Google Search tool provides immediate access to the web’s vast knowledge, while custom function tools let you refine and customize search behavior to your specific requirements.

Creating Your First Search Agent: A Step-by-Step Guide

Let’s get practical and build a search agent that can find and summarize information from the web. Here’s the step-by-step process:

1. Setting Up Your Project Structure

First, ensure you have ADK installed in your virtual environment:

pip install google-adk

Create a project folder structure that follows ADK conventions:

parent_folder/      <-- navigate to this directory
    basic_search_agent/
        __init__.py
        agent.py
        .env

2. Implementing the Search Agent

In your agent.py file, you'll define your agent with the Google Search tool:

from google.adk.agents import Agent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.adk.tools import google_search
from google.genai import types

APP_NAME="google_search_agent"
USER_ID="user1234"
SESSION_ID="1234"


root_agent = Agent(
    name="basic_search_agent",
    model="gemini-2.0-flash",
    description="Agent to answer questions using Google Search.",
    instruction="I can answer your questions by searching the internet. Just ask me anything!",
    # google_search is a pre-built tool which allows the agent to perform Google searches.
    tools=[google_search]
)

# Session and Runner
session_service = InMemorySessionService()
session = session_service.create_session(app_name=APP_NAME, user_id=USER_ID, session_id=SESSION_ID)
runner = Runner(agent=root_agent, app_name=APP_NAME, session_service=session_service)


# Agent Interaction
def call_agent(query):
    """
    Helper function to call the agent with a query.
    """
    content = types.Content(role='user', parts=[types.Part(text=query)])
    events = runner.run(user_id=USER_ID, session_id=SESSION_ID, new_message=content)

    for event in events:
        if event.is_final_response():
            final_response = event.content.parts[0].text
            print("Agent Response: ", final_response)

call_agent("what's the latest ai news?")
GOOGLE_GENAI_USE_VERTEXAI=FALSE
GOOGLE_API_KEY="key"
from . import agent

This simple configuration creates a powerful agent that can now search the web and process the results. The magic happens in how ADK connects the Gemini model’s reasoning capabilities with Google’s search infrastructure.

3. Enhancing Your Agent with Custom Tools

While the built-in search tool is powerful, you might want to extend your agent’s capabilities with custom functions. Here’s how you can add a time function alongside search:

Basic search agent using google adk

Best Practices for Building Effective Search Agents

From the ADK documentation and experience, here are critical best practices to follow:

  1. Be Specific with Return Values When creating custom tools, always return dictionaries with descriptive keys. Instead of returning raw results, structure them with clear labels

  2. Clear Docstrings are Essential The agent determines when to call a function based on its docstring, so make them clear and comprehensive.

  3. Type Annotations Matter Always specify parameter types to help the agent understand what inputs are expected.

  4. Avoid Default Parameters As mentioned in the documentation, default parameters don’t work in ADK (at least in the current version), so explicitly define all required parameters.

  5. Be Aware of Tool Combination Limitations Currently, ADK has some limitations when combining tool types:

  • You can only use one built-in tool at a time

  • You can’t mix built-in tools with custom function tools

  • You can use multiple custom function tools together

Join Yash on Peerlist!

Join amazing folks like Yash and thousands of other people in tech.

Create Profile

Join with Yash’s personal invite link.

0

11

0