Foundation.
Build your first agent with Google's Agent Development Kit. Start from the Agent Starter Pack baseline and add a custom Python tool the model can call.
In this module, we will explore the fundamentals of the Google Agent Development Kit (ADK). We start with a basic agent that can answer questions about the current time and weather. This agent is representative of the default agent generated by the Agent Starter Pack.
Before You Begin
Ensure your workspace is synchronized with the starting state for this module:
make catchup module=01
[!NOTE] This command safely resets your
workspace/to the known good starting point for Module 01.
Building Your First Agent
The baseline agent.py contains a straightforward root agent configuration.
1. Run the ADK Web UI
Execute make adk-web (or adk web path/to/agent) from your terminal. Try talking to your agent and see what it can do before you begin making modifications!
2. Add a Custom Function: get_weather()
Your objective is to add a function tool that returns the current weather conditions for a given city. The tool should return a random temperature (e.g. -10 to 40 degrees Celsius) and weather conditions (sunny, cloudy, raining, etc.).
[!IMPORTANT] The example below uses Python’s
randommodule, which the starter file does not import yet. Addimport randomto the imports at the top ofagent.py(next toimport datetime) — otherwise the agent will crash withNameError: name 'random' is not definedthe first time it calls the tool.
Implementation Example:
import random # add this to the imports at the top of agent.py
def get_weather(city: str) -> str:
"""Simulates getting the current weather conditions for a given city.
Args:
city: The city to get the weather conditions for.
Returns:
A string with the simulated weather conditions for the queried city.
"""
temperature = random.randint(-10, 40)
conditions = random.choice(["sunny", "cloudy", "rainy", "windy", "snowy"])
return f"The weather in {city} is {temperature} degrees Celsius and {conditions}."
3. Register the Tool
Once your function is written, you must explicitly bind it to your ADK Agent instance:
root_agent = Agent(
name="root_agent",
model=Gemini(model="gemini-3.7-flash"),
instruction="You are a helpful AI assistant designed to provide accurate and useful information.",
tools=[get_current_server_time, get_weather], # <-- Add the tool here!
)
Getting unstuck
If you fall behind or your code isn’t working, you can instantly catch up to the beginning of the next module by running:
make catchup module=02
(Note: This will completely overwrite your current workspace/ with the known good baseline for the next module!)
Resources
- LLM Agents Overview: A comprehensive guide on defining an
Agentinstance, detailing core parameters like instruction and naming. - Function Tools Documentation: Detailed instructions on how to transform regular Python functions into ADK-compatible tools by equipping them to an agent.
- Python Quickstart: A practical guide that demonstrates both creating a basic agent and equipping it with a custom Python function.
- ADK Python Samples: Basic Chat: The official collection of reference implementations showing simple agent architectures.