Creating Tools
Create tools for your agents. With ADK, tools can be created using a Python program or an OpenAPI specification.
Creating Python-Based Tools
Python tools are created based on the functions of a Python file. To create a Python-based tool, include the @tool
decorator and a docstring in your python function. These elements identify the function to be converted into a tool and provide a description that helps the agent understand the tool’s usage.
Apart from the mandatory @tool
decorator and docstring, you can design your Python function as needed to perform the desired actions. If your function requires inputs and outputs, you can use native Python types and Pydantic typings.
Python tool example
If your Python function relies on external libraries or packages, you can ensure your tool works correctly by specifying these dependencies in the requirements.txt
file.
Python tool example
requirements.txt example
Creating OpenAPI based tools
OpenAPI tools are created based on an OpenAPI specification file. To import an OpenAPI tool, configure the servers
and paths
properties; the entire OpenAPI specification file is not required.
OpenAPI tool example