Building AI Agents with ADK: Empowering with Tools

Building AI Agents with ADK:
Empowering with Tools

About this codelab

subjectLast updated Jul 17, 2025
account_circleWritten by Thu Ya Kyaw

1. Before you begin

Welcome to the second part of the "Building AI Agents with ADK" series! In this hands-on codelab series, you'll embark on an exciting journey to create your very own intelligent AI agent using Google's Agent Development Kit (ADK).

This codelab picks up from where the ADK foundation codelab left off. We'll assume you've already completed the necessary setups and successfully built your personal assistant agent using ADK at this point, so we won't repeat those setup steps here.

By the end of this codelab, you'll have empowered your personal assistant agent with tools for various purposes, one step closer to be expanded upon in subsequent parts of this series as we transform it into a sophisticated Multi-Agent System (MAS).

What you'll learn

  • Give your agent new skills by building custom Python functions as tools.
  • Connect your agent to real-time information using built-in tools like Google Search.
  • Structure a multi-tool agent by creating specialized sub-agents for complex tasks.
  • Integrate tools from popular AI frameworks like LangChain to rapidly expand capabilities.

What you'll need

  • A working computer and reliable wifi
  • A browser, such as Chrome, to access Google Cloud Console
  • A Google Cloud Project with billing enabled
  • A curious mind and eagerness to learn

2. Introduction

In the ADK foundation codelab, you built a personal assistant agent with a powerful LLM brain. However, you likely noticed its limitations: it can't access information created after its training date, and it can't interact with external services. It's like a brilliant, book-smart assistant locked in a library with no phone or internet.

To make our agent truly useful, we need to give it tools.

Think of tools as giving that brilliant assistant access to the outside world: a calculator, a web browser, or access to a specific company database. In ADK, a tool is a modular piece of code that allows the agent to perform specific actions like looking up real-time data or calling an external API. Using tools extends its capabilities far beyond simple conversation.

ADK offers three categories of tools:

  1. Function Tools: Custom tools you develop to meet your application's unique requirements, such as predefined functions and agents.
  2. Built-in Tools: Ready-to-use tools provided by the framework for common operations, like Google Search and Code Execution.
  3. Third-party Tools: Popular external libraries such as Serper and tools from LangChain and CrewAI.

To learn more about using Tools with ADK Agents, have a look at the official documentation. In this codelab, we will add tools to transform our simple agent into a capable personal travel assistant. Let's begin!

3. Add a Function Tool

Continuing from our last session, you should have a personal assistant agent running via web interface.

7b779b9601941a12.png

Imagine you're preparing for a trip to Japan next month and need to check the current currency exchange rate. Ask the agent:

What is the exchange rate from Singapore dollars to Japanese yen?

a8f38e3c404ada9c.png

You'll see that the agent can't retrieve real-time exchange rates. This is because the agent currently lacks internet access and external system connectivity. To address this, we will implement a Python function to retrieve exchange rates via a REST API and integrate it as a Function Tool for the agent.

First, terminate the running agent process by using the keyboard shortcut Ctrl + C (for Windows/Linux) or Cmd + C (for macOS).

Following that, create a Python file named custom_functions.py. This file will contain the Python function responsible for retrieving exchange rate data from an external API.

Creating custom_functions.py:

import requests

# define a function to get exchange rate
def get_fx_rate(base: str, target: str):
        """
        Fetches the current exchange rate between two currencies.

        Args:
                base: The base currency (e.g., "SGD").
                target: The target currency (e.g., "JPY").

        Returns:
                The exchange rate information as a json response,
                or None if the rate could not be fetched.
        """
       
base_url = "https://hexarate.paikama.co/api/rates/latest"
       
api_url = f"{base_url}/{base}?target={target}"

       
response = requests.get(api_url)
       
if response.status_code == 200:
               
return response.json()

Now, edit the agent.py file: import get_fx_rate function and assign it as a FunctionTool.

Updating agent.py:

from google.adk.agents import Agent
from google.adk.tools import FunctionTool

from .custom_functions import get_fx_rate

root_agent = Agent(
   
model='gemini-2.0-flash-001',
   
name='root_agent',
   
description='A helpful assistant for user questions.',
   
instruction='Answer user questions to the best of your knowledge',
   
tools=[FunctionTool(get_fx_rate)]
)

After the changes, start the agent again by typing:

uv run adk web

When the agent is up, ask the same question again:

What is the exchange rate from Singapore dollars to Japanese yen?

This time around you should see the actual exchange rate given by the get_fx_rate tool.

4f671fe04f8421f5.png

Feel free to ask any currency exchange related questions as you wish.

4. Add a Built-in Tool

With the agent now capable of providing exchange rates, the next task is to obtain next month's weather forecast. Ask this question to the agent:

What is the weather forecast in Tokyo, Japan for next month?

96c175077957fdd0.png

As you might expect, the weather forecast requires real-time information which our agent doesn't have. While we could code new Python functions for each piece of required real-time data, adding more and more custom tools quickly makes the agent too complicated and difficult to manage.

Fortunately, the Agent Development Kit (ADK) provides a suite of built-in tools, including Google Search that are ready to use, simplifying how our agent interacts with the outside world. Let's add a Google Search tool to our agent. To do that you need to edit the agent.py file as:

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

from .custom_functions import get_fx_rate

root_agent = Agent(
   
model='gemini-2.0-flash-001',
   
name='root_agent',
   
description='A helpful assistant for user questions.',
   
instruction='Answer user questions to the best of your knowledge',
   
tools=[
       
FunctionTool(get_fx_rate),
       
google_search,
   
]
)

Once you have edited the file, restart the adk web instance. In case you forget,

  1. Click on the terminal, press Ctrl + C or Cmd + C to stop the instance
  2. uv run adk web to start the instance

You will encounter an error!

This error is intentional and teaches a core architectural principle of the ADK. To avoid ambiguity and keep agent design clean, an agent is designed to use only one primary search-based tool. You cannot simply list google_search alongside other complex tools in the same agent.

The correct approach is to embrace a multi-agent pattern: we create a new, specialized agent whose only job is to perform Google searches. Then, we give this search agent to our main personal_assistant as a tool.

Now, create a Python file named custom_agents.py. This file will contain the code for the specialized google_search_agent. Copy the following code to the custom_agents.py file.

Creating custom_agents.py

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


# Create an agent with google search tool as a search specialist
google_search_agent = Agent(
   
model='gemini-2.0-flash-001',
   
name='google_search_agent',
   
description='A search agent that uses google search to get latest information about current events, weather, or business hours.',
   
instruction='Use google search to answer user questions about real-time, logistical information.',
   
tools=[google_search],
)

Once the file is created, update the agent.py file as shown below.

Updating agent.py

from google.adk.agents import Agent
from google.adk.tools import FunctionTool
from google.adk.tools import agent_tool

from .custom_functions import get_fx_rate
from .custom_agents import google_search_agent


root_agent = Agent(
   
model='gemini-2.0-flash-001',
   
name='root_agent',
   
description='A helpful assistant for user questions.',
   
tools=[
       
FunctionTool(get_fx_rate),
       
agent_tool.AgentTool(agent=google_search_agent),
   
]
)

Let's break down the powerful new pattern in the code:

  • A New Specialist Agent: We've defined a completely new agent, google_search_agent. Note its specific description and that its only tool is google_search. It's a search specialist.
  • agent_tool.AgentTool: This is a special wrapper from the ADK. It takes an entire agent (our google_search_agent) and packages it to look and act like a standard tool.
  • A Smarter **root_agent**: Our root_agent now has a new tool: agent_tool.AgentTool(agent=google_search_agent). It doesn't know how to search the web, but it knows it has a tool it can delegate search tasks to.

Notice the instruction field is gone from root_agent. Its instructions are now implicitly defined by the tools it has available. It has become an orchestrator or a router, whose main job is to understand a user's request and pass it to the correct tool, either the get_fx_rate function or the google_search_agent. This decentralized design is key to building complex, maintainable agent systems.

Now, restart the adk web instance and ask this question to the agent again:

What is the weather forecast in Tokyo, Japan for next month?

9771716f64132c54.png

The agent is now using google_search_agent to get latest information

You can try asking a current exchange question too. The agent should now be able to use the right tool for the respective question.

2a8e6525a9f5a4ee.png

Feel free to ask other questions that require real-time information to the agent and observe how it handles the queries using the tools at its disposal.

5. Add a Third-party Tool

Our agent is shaping up to be a great travel assistant. It can handle currency exchange with its get_fx_rate tool and manage logistics with its google_search_agent tool. But a great trip isn't just about logistics; it's about understanding the culture and history of your destination.

While google_search_agent tool can provide culture and history information based on search results, you would want to get such information from a more reliable source like Wikipedia. Similarly, you could create your own Python function that scrapes the information from Wikipedia, but there has to be a better way.

Fortunately, ADK is designed to be highly extensible, allowing you to seamlessly integrate tools from other AI Agent frameworks like CrewAI and LangChain. This interoperability is crucial because it allows for faster development time and allows you to reuse existing tools. For this use case, we will leverage the Wikipedia tools from LangChain.

First, stop the running agent process (Ctrl + C or Cmd + C) and install additional libraries to the current Python virtual environment.

uv add langchain-community
uv add wikipedia

Once the installation is completed. Create a file called third_party_tools.py. This file will contain the implementation for LangChain Wikipedia tool.

Creating third_party_tools.py

from langchain_community.tools import WikipediaQueryRun
from langchain_community.utilities import WikipediaAPIWrapper

# Configure the Wikipedia LangChain tool to act as our cultural guide
langchain_wikipedia_tool = WikipediaQueryRun(
   
api_wrapper=WikipediaAPIWrapper(top_k_results=1, doc_content_chars_max=3000)
)

# Give the tool a more specific description for our agent
langchain_wikipedia_tool.description = (
   
"Provides deep historical and cultural information on landmarks, concepts, and places."
   
"Use this for 'tell me about' or 'what is the history of' type questions."
)

Now. update the agent.py file.

Updating agent.py

from google.adk.agents import Agent
from google.adk.tools import FunctionTool
from google.adk.tools import agent_tool
from google.adk.tools import langchain_tool

from .custom_functions import get_fx_rate
from .custom_agents import google_search_agent
from .third_party_tools import langchain_wikipedia_tool


root_agent = Agent(
   
model='gemini-2.0-flash-001',
   
name='root_agent',
   
description='A helpful assistant for user questions.',
   
tools=[
       
FunctionTool(get_fx_rate),
       
agent_tool.AgentTool(agent=google_search_agent),
       
langchain_tool.LangchainTool(langchain_wikipedia_tool),
   
]
)

Now, restart the adk web instance and ask this question to the agent again:

Tell me about the history of Kyoto

862ec3546a8fbb5f.png

The agent correctly identifies this as a historical query and uses its new Wikipedia tool. By integrating a third-party tool and giving it a specific role, you've made your agent significantly more intelligent and useful for its travel-planning purpose.

To see exactly how the agent made this choice, you can use the event inspector in the adk web UI. Click on the Events tab and then on the most recent functionCall event.

e3f388b64d08e666.png

The inspector shows a list of all available tools and highlights the tool_code for the one that was executed by the agent.

135c9a1068d6c58f.png

6. Clean Up

Since this codelab doesn't involve any long-running products, simply stopping your active agent sessions (e.g., the adk web instance in your terminal) by pressing Ctrl + C in the terminal is sufficient.

Delete Agent Project Folders and Files

If you only want to remove the code from your Cloud Shell environment, use the following commands:

cd ~
rm -rf ai-agents-adk

Disable Vertex AI API

To disable the Vertex AI API that was enabled earlier, run this command:

gcloud services disable aiplatform.googleapis.com

Shut Down the Entire Google Cloud Project

If you wish to fully shut down your Google Cloud project, refer to the official guide for detailed instructions.

7. Conclusion

Congratulations! You've successfully empowered the personal assistant agent with custom functions and real-time Google Search access.

More importantly, you have learned the fundamental architectural pattern for building capable agents: using specialized agents as tools. By creating a dedicated google_search_agent and giving it to your root_agent, you've taken your first step from building a single agent to orchestrating a simple, yet powerful, multi-agent system.

You are now perfectly prepared for the next codelab in the series, where we will dive deeper into orchestrating multiple agents and workflows. See you there!