
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Install ADK and set up your environment
/ 20
Create a data store
/ 20
Use a LangChain Tool
/ 20
Use a CrewAI Tool
/ 20
Use a Google-provided tool
/ 10
Use a function as a custom tool
/ 10
This lab covers the use of tools with Agent Development Kit agents.
From powerful tools provided by Google, like Google Search and Vertex AI Search, to the rich variety of tools available in the LangChain and CrewAI ecosystems, there are many tools to get started with.
Additionally, creating your own tool from a function only requires writing a good docstring!
This lab assumes you are familiar with the basics of ADK covered in the lab Get started with Agent Development Kit (ADK).
In this lab, you will learn about the ecosystem of tools available to ADK agents. You will also learn how to provide a function to an agent as a custom tool.
After this lab, you will be able to:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.
This Qwiklabs hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab.
Note: If you are using a Pixelbook, open an Incognito window to run this lab.
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Leveraging tools effectively is what truly distinguishes intelligent agents from basic models. A tool is a block of code, like a function or a method, that executes specific actions such as interacting with databases, making API requests, or invoking other external services.
Tools empower agents to interact with other systems and perform actions beyond their core reasoning and generation capabilities. It's crucial to note that these tools operate independently of the agent's LLM, meaning that tools do not automatically possess their own reasoning abilities.
Agent Development Kit provides developers with a diverse range of tool options:
In this lab, you will explore these categories and implement one of each type.
Google provides several useful tools for your agents. They include:
Google Search (google_search
): Allows the agent to perform web searches using Google Search. You simply add google_search
to the agent's tools.
Code Execution (built_in_code_execution
): This tool allows the agent to execute code, to perform calculations, data manipulation, or interact with other systems programmatically. You can use the pre-built VertexCodeInterpreter
or any code executor that implements the BaseCodeExecutor
interface.
Retrieval (retrieval
): A package of tools designed to fetch information from various sources.
Vertex AI Search Tool (VertexAiSearchTool
): This tool integrates with Google Cloud's Vertex AI Search service to allow the agent to search through your AI Applications data stores.
With your Google Cloud console window selected, open Cloud Shell by pressing the G key and then the S key on your keyboard. Alternatively, you can click the Activate Cloud Shell button () in the upper right of the Cloud console.
Click Continue.
When prompted to authorize Cloud Shell, click Authorize.
In the upper right corner of the Cloud Shell Terminal panel, click the Open in new window button .
In the Cloud Shell Terminal, enter the following to open the Cloud Shell Editor to your home directory:
Update your PATH
environment variable and install ADK by running the following commands in the Cloud Shell Terminal. Note: You will specify the version to ensure that the version of ADK that you install corresponds to the version used in this lab:
Paste the following commands into the Cloud Shell Terminal to copy a file from a Cloud Storage bucket, and unzip it, creating a project directory with code for this lab:
Install additional lab requirements with:
Click Check my progress to verify the objective.
In a later task, you will use the Google-provided Vertex AI Search tool to ground responses on your own data in an AI Applications data store. Since this data store needs a little while to ingest data, you will set it up now, then use it to ground responses on your data in a later task.
Example documents have been uploaded to Cloud Storage for you. They relate to the fictional discovery of a new planet named Persephone. (A fictional planet is used in this case so that the model cannot have learned anything about this planet during its training.)
-bucket/planet-search-docs
.Planet Search
.Click Check my progress to verify the objective.
ADK allows you to use tools available from third-party AI libraries like LangChain and CrewAI.
The LangChain community has created a large number of tool integrations to access many sources of data, integrate with various web products, and accomplish many things. Using community tools within ADK can save you rewriting a tool that someone has already created.
Back in your browser tab displaying the Cloud Shell Editor, use the file explorer on the left-hand side to navigate to the directory adk_tools/langchain_tool_agent.
Write a .env file to provide authentication details for this agent directory by running the following in the Cloud Shell Terminal:
Copy the .env
file to the other agent directories you will use in this lab by running the following:
Click on the agent.py file in the langchain_tool_agent directory.
Notice the import of the LangchainTool
class. This is a wrapper class that allows you to use LangChain tools within Agent Development Kit.
Add the following code where indicated in the agent.py
file to add the LangChain Wikipedia tool to your agent. This will allow your agent to search for information on Wikipedia:
Save the file.
In the Cloud Shell Terminal, from the adk_tools project directory, launch the Agent Development Kit Dev UI with the following commands:
Output
To view the web interface in a new tab, click the http://127.0.0.1:8000 link in the Terminal output.
A new browser tab will open with the ADK Dev UI.
From the Select an agent dropdown on the left, select the langchain_tool_agent from the dropdown.
Query the agent with:
Output:
Click the agent icon next to the agent's chat bubble indicating the use of the wikipedia tool.
Notice that the content includes a functionCall
with the query to Wikipedia.
At the top of the tab, click the forward button to move to the next event.
On the Request tab, you can see the result retrieved from Wikipedia used to generate the model's response.
When you are finished asking questions of this agent, close the dev UI browser tab.
In the Terminal, press CTRL + C to stop the server.
Click Check my progress to verify the objective.
You can similarly use CrewAI Tools, using a CrewaiTool
wrapper.
To do so, using the Cloud Shell Editor file explorer, navigate to the directory adk_tools/crewai_tool_agent.
Click on the agent.py file in the crewai_tool_agent directory.
Notice the import of the CrewaiTool
class from ADK and the FileWriterTool
from crewai_tools
.
Add the following code where indicated in the agent.py
file to add the CrewAI File Write tool to your agent, along with a name and description:
Save the file.
You'll run this agent using the command line interface to be familiar with it as a convenient way to test an agent quickly. In the Cloud Shell Terminal, from the adk_tools project directory, launch the agent with the ADK command line UI with:
While the agent loads, it may display some warnings. You can ignore these. When you are presented the user:
prompt, enter:
Output:
Notice that the command line interface also indicates to you when a tool is being used.
In the Terminal, respond to the next user:
prompt with exit
to exit the command line interface.
Run the following command to print the poem from the file that the tool created:
Example output (yours may be a little different):
Scroll back in your Terminal history to find where you ran adk run crewai_tool_agent
, and notice that the command line interface provided you a log file to tail. Copy and run that command to view more details of the execution:
Press CTRL + C to stop tailing the log file and return to the command prompt.
Click Check my progress to verify the objective.
In this task, you will discover how easy it is to deploy a RAG application using an Agent Development Kit agent with the built-in Vertex AI Search tool from Google and the AI Applications data store you created earlier.
Return to your Cloud Shell Editor tab and select the adk_tools/vertexai_search_tool_agent directory.
Click on the agent.py file in the vertexai_search_tool_agent directory.
Notice the import of the VertexAiSearchTool
class:
Update the code where the VertexAiSearchTool
is instantiated. In the path being passed to data_store_id
, update YOUR_PROJECT_ID
to YOUR_DATA_STORE_ID
to the data store ID you copied earlier.
Add the following line where indicated in the agent definition to provide the agent the tool:
You can confirm your data store is ready for use by selecting the data store's name on the AI Applications > Data Stores page in the console.
The ACTIVITY and DOCUMENTS tabs provide statuses on the import and indexing of your documents. When the ACTIVITY tab reports "Import completed", your data store should be ready to query.
In the Cloud Shell Terminal, from the adk_tools project directory, launch the command line interface with the following command:
adk web
session, the default port of 8000 will be blocked, but you can launch the Dev UI with a new port by using adk web --port 8001
, for example.
Click the http://127.0.0.1:8000 to open the ADK Dev UI.
From the Select an agent dropdown on the left, select the vertexai_search_tool_agent and toggle on the Token Streaming option in the upper right.
Query the agent about the fictional planet described in your Cloud Storage documents with:
Example output (yours may be a little different)
Click Check my progress to verify the objective.
When pre-built tools don't fully meet specific requirements, you can create your own tools. This allows for tailored functionality, such as connecting to proprietary databases or implementing unique algorithms.
The most straightforward way to create a new tool is to write a standard Python function with a docstring written in a standard format and pass it to your model as a tool. This approach offers flexibility and quick integration.
When writing a function to be used as a tool, there are a few important things to keep in mind:
"error_message"
key containing a human-readable explanation. As a best practice, include a "status"
key in your return dictionary to indicate the overall outcome (e.g., "success"
, "error"
, "pending"
), providing the LLM with a clear signal about the operation's state.Define a function and use it as a tool by completing the following steps:
Using the Cloud Shell Editor file explorer, navigate to the directory adk_tools/function_tool_agent.
In the function_tool_agent directory, click on the agent.py file.
Notice that the functions get_date()
and write_journal_entry()
have docstrings formatted properly for an ADK agent to know when and how to use them. They include:
Args:
section describing the function's input parameters with JSON-serializable typesReturns:
section describing what the function returns, with the preferred response type of a dict
To pass the function to your agent to use as a tool, add the following code where indicated in the agent.py
file:
Save the file.
You will run this agent using the dev UI to see how its tools allow you to easily visualize tool requests and responses. In the Cloud Shell Terminal, from the adk_tools project directory, run the dev UI again with the following command (if the server is still running from before, stop the running server first with CTRL+C, then run the following to start it again):
Click the http://127.0.0.1:8000 link in the Terminal output.
A new browser tab will open with the ADK Dev UI.
From the Select an agent dropdown on the left, select the function_tool_agent.
Start a conversation with the agent with:
The agent should prompt you about your day. Respond with a sentence about how your day is going, and it will write a journal entry for you.
Example Output:
Notice that your agent shows buttons for your custom tool's request and the response. You can click on each to see more information about each of these events.
Close the dev UI tab.
In the Cloud Shell Editor, you can find your dated journal entry file in the adk_tools directory. (You may want to use the Cloud Shell Editor's menu to enable View > Word Wrap to see the full text without lots of horizontal scrolling.)
To stop the server, click on the Terminal panel and press CTRL + C.
str
and int
over custom classes when possible.update_profile(profile: Profile)
function, create separate functions like update_name(name: str)
, update_age(age: int)
, etc."status"
key in your return dictionary to indicate the overall outcome (e.g., "success"
, "error"
, "pending"
) to provide the LLM a clear signal about the operation's state.Click Check my progress to verify the objective.
The following tool types are good for you to know about, but you will not implement them in this lab.
This tool is a subclass of FunctionTool. It's designed for tasks that require a significant amount of processing time that should be called without blocking the agent's execution.
When using a LongRunningFunctionTool
, your Python function can initiate the long-running operation and optionally return an intermediate result to keep the model and user informed about the progress (e.g., status updates or estimated completion time). The agent can then continue with other tasks.
An example is a human-in-the-loop scenario where the agent needs human approval before proceeding with a task.
This feature allows you to leverage the capabilities of other agents within your system by calling them as tools, effectively delegating responsibility to a 'specialist' agent. This is conceptually similar to creating a Python function that calls another agent with function arguments and uses the agent's response as the function's return value.
With Application Integration, you can use a drag-and-drop interface in the Google Cloud Console to build tools, data connections, and data transformations using Integration Connector’s 100+ pre-built connectors for Google Cloud products and third-party systems like Salesforce, ServiceNow, JIRA, SAP, and more. You can then use an ADK ApplicationIntegrationToolset
to allow your agents to connect to those sources or call your workflows.
Model Context Protocol (MCP) is an open standard designed to standardize how Large Language Models (LLMs) like Gemini and Claude communicate with external applications, data sources, and tools. ADK helps you both use and consume MCP tools in your agents, whether you're trying to build a tool to call an MCP service, or exposing an MCP server for other developers or agents to interact with your tools.
Refer to the MCP Tools documentation for code samples and design patterns that help you use ADK together with MCP servers, including:
In this lab, you’ve learned to:
To learn more about building and deploying agents using Agent Development Kit, check out these labs:
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated May 22, 2025
Lab Last Tested May 22, 2025
Copyright 2023 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one