An ADK agent that demonstrates creating custom function tools. This agent uses a FunctionTool to check order status.
This agent shows how to create custom tools using the FunctionTool wrapper. The agent can check the status of orders using a custom function.
What is a Function Tool? A Function Tool allows you to wrap any Python function and make it available to your ADK agent. The agent can automatically call these functions based on user queries, enabling it to perform custom operations beyond built-in capabilities.
adk_custom_tool_agent/
├── agent.py # Main agent code with custom FunctionTool
├── __init__.py # Package initialization
└── .env.example # Example environment variables template
- Python 3.11 or later
- Google ADK installed (see parent directory README for installation instructions)
- Google API key from Google AI Studio
- Create a
.envfile with your API key and configuration:
Copy the example environment file and update it with your API key:
cp .env.example .envThen edit .env and replace "your-api-key" (or "YOUR_API_KEY") with your actual Google API key.
Environment Variables:
GOOGLE_GENAI_USE_VERTEXAI=False: Use AI Studio (Gemini API) instead of Vertex AIGOOGLE_API_KEY: Your Google API key from Google AI Studio
From the 1_adk_tools directory:
adk run adk_custom_tool_agentFrom the 1_adk_tools directory:
adk webThen open the URL shown in the terminal (typically http://localhost:8000) in your browser and select the agent.
- Google ADK Version:
1.18.0 - Model:
gemini-2.5-flash - Tool: Custom
FunctionToolwrappingget_order_statusfunction - Capabilities: Check order status by order ID
The agent includes a custom function:
def get_order_status(order_id: str):
"""Retrieves the status of an order by order ID."""
return {"order_id": order_id, "status": "Shipped", "delivery_date": "Nov 4, 2025"}This function is wrapped with FunctionTool to make it available to the agent:
tools=[FunctionTool(get_order_status)]You can extend this example by:
- Connecting to a real order database
- Adding more order-related functions
- Implementing authentication
- Adding error handling
