Build Powerful AI Agents with Google ADK Tools and Best Practices- #2 ADK Blog Series
Hello, and welcome back to the TechTrapture blog! As we navigate the complex intersection of Cloud, AI, and Data Analytics, the ability for an AI agent to move beyond mere conversation and actually take action is the game-changer. This is where the Google Agent Development Kit (ADK) truly shines.
In our previous discussions, we covered the foundational architecture. Now, let’s shift our focus to the component that gives our agents their practical “superpowers”: Tools.
0. Quick Recap — What Is ADK?
The Agent Development Kit (ADK) is Google’s modular framework for building, testing, and deploying intelligent AI agents.
It provides the main building blocks:
- 🧠 Agents — handle reasoning and logic
- 🧰 Tools — take real-world actions
- 💾 Memory — store and recall context
- ⚙️ Runtimes — manage execution
Think of it like this:
The agent is the brain, but the tools are its hands and feet — allowing it to act in the real world
🎥 Watch & Learn: If you want to see these concepts in action, check out my full Google ADK playlist on YouTube . Each video walks you step-by-step, from building a starter agent to using tools like BigQuery and Google Search.
1. What Are Tools in ADK?
In the ADK ecosystem, a Tool is essentially an action module — a piece of code that the agent can invoke to do something outside pure text generation and reasoning. Tools are the hands and feet of your agent; they are not the brain.
The process of tool usage is simple yet powerful:
- The agent’s Large Language Model (LLM) reasons over the request and decides which tool to call and with what arguments.
- ADK handles the invocation of the tool, executing the custom or built-in code.
- The agent receives the tool’s output (the Observation) and uses that information to continue its reasoning or produce a final, grounded response.
This mechanism grants your agent the ability to access real-time APIs, query massive datasets like BigQuery, or execute specific logic, effectively overcoming the limitations inherent in its training data.
2. How Agents Use Tools (Simple Explanation)
Agents can use external tools — such as BigQuery or Google Search — to find or process information they don’t already know.
Here’s how it works step by step:
- Think (Reasoning): The agent reads your question and figures out what you need.
- Choose a Tool (Selection): It decides which tool can help — for example, BigQuery if you asked for database insights, or Google Search if you want the latest web info.
- Run the Tool (Invocation): It prepares the right inputs and runs the tool.
- Get Results (Observation):Captures thetool’s output. The tool returns results — like a query output or search snippet.
- Respond: The agent uses that data to answer you clearly.
🧪 Example Queries & Agent Behavior
Query 1 (no tool needed):
“Can you write a blog for me on the topic ‘Agentic AI’?”
How the agent handles it:
Reasoning — The agent sees that this is a content-creation request. It doesn’t require external data or real-time facts; the agent has enough internal knowledge to generate the blog.
Decision — It decides not to call any tool (because none is necessary).
Generate response — It writes the blog directly, possibly structuring sections (introduction, main parts, conclusion), giving examples, etc.
Return answer — It sends the blog text back to the user.
Result: The user gets a full blog draft immediately, no tool invocation.
Example 2 — Tool Needed (BigQuery)
User Query:
“How many datasets do I have in my BigQuery project <project id>?”
🔹 How the Agent Handles It:
Reasoning:
The agent realizes it can’t know your project data by itself — it needs to query BigQuery.
Decision:
It decides to call the BigQuery Tool (or API) that connects to your Google Cloud project.
Invocation:
It prepares and runs a simple SQL command using the BigQuery tool:
SELECT COUNT(*) AS dataset_count FROM `region-us`.INFORMATION_SCHEMA.SCHEMATA;
SELECT *AS dataset_count FROM `region-us`.INFORMATION_SCHEMA.SCHEMATA;Observation:
The tool returns something like:
functionResponse:
id: "adk-c3cc14cf-7eb4-43f7-b51d-75fe6557aee7"
name: "list_dataset_ids"
response:
result:
0: "Aravind_DS"
1: "File_Formats_Dataset"
2: "airflow_demo"
3: "billing_data"
4: "cloud_function"
5: "datafusion"
6: "dataproc_demo"
7: "datastream"
8: "dbt_ajay"
9: "demo"
10: "df_demo"
11: "elt"
12: "gcp_july_demo"
13: "july_tf"
14: "ravi_dev"
15: "ravi_prod"
16: "reporting"
17: "security_demo"
18: "staging"
19: "test_log"
20: "transform"Finalization:
The agent reads the result and forms a natural reply.
👉 In short:
The agent is the brain; tools like BigQuery and Google Search are its hands.
It decides when and how to use those tools to get the right answer.
3. Tool Types in ADK
ADK offers flexibility by supporting several types of tools:
Function Tools: Tools created by you, tailored to your specific application’s needs.
- Functions/Methods: Define standard synchronous functions or methods in your code (e.g., Python def).
from google.adk.agents import Agent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types
import yfinance as yf
def get_stock_price(symbol: str):
"""
Retrieves the current stock price for a given symbol.
Args:
symbol (str): The stock symbol (e.g., "AAPL", "GOOG").
Returns:
float: The current stock price, or None if an error occurs.
"""
try:
stock = yf.Ticker(symbol)
historical_data = stock.history(period="1d")
if not historical_data.empty:
current_price = historical_data['Close'].iloc[-1]
return current_price
else:
return None
except Exception as e:
print(f"Error retrieving stock price for {symbol}: {e}")
return None
stock_price_agent = Agent(
model='gemini-2.0-flash',
name='stock_agent',
instruction= 'You are an agent who retrieves stock prices. If a ticker symbol is provided, fetch the current price. If only a company name is given, first perform a Google search to find the correct ticker symbol before retrieving the stock price. If the provided ticker symbol is invalid or data cannot be retrieved, inform the user that the stock price could not be found.',
description='This agent specializes in retrieving real-time stock prices. Given a stock ticker symbol (e.g., AAPL, GOOG, MSFT) or the stock name, use the tools and reliable data sources to provide the most up-to-date price.',
tools=[get_stock_price], # You can add Python functions directly to the tools list; they will be automatically wrapped as FunctionTools.
)
- Agents-as-Tools: Use another, potentially specialized, agent as a tool for a parent agent.
- Long Running Function Tools: Support for tools that perform asynchronous operations or take significant time to complete.
Built-in Tools: Ready-to-use tools provided by the framework for common tasks. Examples: Google Search, Code Execution, Retrieval-Augmented Generation (RAG).
⚠️ You can only attach one built-in tool per root agent.
If you need more, use Agents-as-Tools or multi-agent design (we’ll explore that in another post).
Below example uses Google Search Built in Tool
from google.adk.agents import Agent
from google.adk.tools import google_search
root_agent = Agent(
name = "my_first_agent",
model = "gemini-2.0-flash",
description = "An example agent that will answer user query based on Google Search",
instruction = """
You are a helpful assistant that provides information based on user queries.
""",
tools = [google_search])Third-Party Tools: Integrate tools seamlessly from popular external libraries. Examples: LangChain Tools, CrewAI Tools.
Below example includes langchain Wikipedia Tool
import os
import sys
sys.path.append("..")
import google.cloud.logging
from google.adk import Agent
from google.adk.tools.langchain_tool import LangchainTool # import
from langchain_community.tools import WikipediaQueryRun
from langchain_community.utilities import WikipediaAPIWrapper
from dotenv import load_dotenv
load_dotenv()
cloud_logging_client = google.cloud.logging.Client()
cloud_logging_client.setup_logging()
root_agent = Agent(
name="lanchgain_tool_agent",
model=os.getenv("MODEL"),
description="Answers questions using Wikipedia.",
instruction="""Research the topic suggested by the user.
Share the information you have found with the user.""",
tools = [
LangchainTool(
tool=WikipediaQueryRun(
api_wrapper=WikipediaAPIWrapper()
)
)
]
)Google Cloud Tools:Google Cloud tools make it easier to connect your agents to Google Cloud’s products and services. With just a few lines of code you can use these tools to connect your agents with:
MCP Tools: The MCPToolset class is ADK's primary mechanism for integrating tools from an MCP server. When you include an MCPToolset instance in your agent's tools list, it automatically handles the interaction with the specified MCP server.
Below example use simple MCP Server as Tool.
import os # Required for path operations
from google.adk.agents import LlmAgent
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
from mcp import StdioServerParameters
TARGET_FOLDER_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "/path/to/your/folder")
root_agent = LlmAgent(
model='gemini-2.0-flash',
name='filesystem_assistant_agent',
instruction='Help the user manage their files. You can list files, read files, etc.',
tools=[
MCPToolset(
connection_params=StdioConnectionParams(
server_params = StdioServerParameters(
command='npx',
args=[
"-y", # Argument for npx to auto-confirm install
"@modelcontextprotocol/server-filesystem",
os.path.abspath(TARGET_FOLDER_PATH),
],
),
),
)
],
)Defining Effective Tool Functions with Best Practices
When using a method or function as an ADK Tool, how you define it significantly impacts the agent’s ability to use it correctly. The agent’s Large Language Model (LLM) relies heavily on the function’s name, parameters (arguments), type hints, and docstring / source code comments to understand its purpose and generate the correct call.
As experts building production-grade agents, we know that the code we write isn’t just for a compiler — it’s for the LLM. Precision in definition is key for reliability.
I. Naming for Intent: Clarity in Action
- Rule: Use descriptive, verb-noun based names that clearly indicate the action (e.g.,
get_weather,search_documents). Avoid generic names likerunordoStuff.
II. Parameter Design: Guiding the Input
- Provide Type Hints: This is essential for ADK to generate the correct schema for the LLM (e.g.,
city: str,user_id: int). - JSON Safe: Ensure all parameter types are JSON serializable.
- No Default Values: Do not set default values for parameters. The LLM should derive or request all necessary input.
- Implicit Parameters:
selforclsare automatically handled and excluded from the LLM's view.
III. Structured Output: The LLM’s Observation
- Return a Dictionary (or Map): The function’s return value must be a dictionary (dict) in Python.
- Include a Status Key: Highly recommended practice: include a
statuskey (e.g.,'success','error') to clearly indicate the outcome of the execution for the model.
IV. The Docstring: The LLM’s Primary Manual
The docstring is the most critical element for tool definition.
- Be Specific: Clearly state what the tool does, when it should be used, and its limitations.
- Describe Everything: Describe each parameter, and describe the structure and meaning of the expected dictionary return value.
- Crucial Exclusion: Do not describe the injected
ToolContextparameter in the docstring, as the LLM does not need to know about it.
V. Simplicity and Focus
- Keep Tools Focused: Each tool should perform one well-defined logical task.
- Decompose Complex Tasks: Break down functions that perform multiple steps into smaller, focused tools to make it easier for the LLM to select the right capability.
VI. Utilizing Toolsets: Grouping Related Capabilities
To manage complexity and maintain clarity, especially as your agent gains more capabilities, the ADK framework allows you to group related tools into a Toolset.
A Toolset acts as a container for multiple functions or methods. Using a Toolset offers several organizational and practical benefits:
- Logical Grouping: It keeps related functionalities — like all BigQuery functions, or all HR-related APIs — organized together.
- Dynamic Provisioning: You can dynamically provide or inject entire sets of tools into an agent based on the context of the session or the user’s role.
- Scalability: When dealing with agents that possess dozens of potential actions, grouping them into toolsets makes the agent’s overall configuration much cleaner and more manageable.
Conclusion
With Google ADK, your agents aren’t just smart — they’re capable. Tools transform an agent’s internal reasoning into real-world actions, whether that’s searching the web, querying BigQuery, or interacting with external systems via MCP.
By understanding how to define tools clearly, select the right tool at the right time, and organize multiple tools into Toolsets, you can create AI agents that are reliable, efficient, and genuinely helpful.
Think of your agent as a brain with hands and feet — the better you equip it, the more it can do. In the next post, we’ll explore connecting agents to live systems using MCP servers, giving them true “superpowers” in real-time applications.
About Me
As an experienced Fully certified (11x certified) Google Cloud Architect, Google Developer Expert (GDE), with over 9+ years of expertise in Google Cloud Networking,Data ,Devops, Security and AI/ML, I am passionate about technology and innovation. Being a Google Developer Expert(GDE) and Google Cloud Architect, I am always exploring new ways to leverage cloud technologies to deliver innovative solutions that make a difference.
If you have any queries or would like to get in touch, you can reach me at Email address — vishal.bulbule@techtrapture.com or connect with me on LinkedIn at https://www.linkedin.com/in/vishal-bulbule/. For a more personal connection, you can also find me on Instagram at https://www.instagram.com/vishal_bulbule/?hl=en.
Additionally, please check out my YouTube Channel at https://www.youtube.com/@techtrapture for tutorials and demos on Google Cloud.

