Google ADK 2.0 shipped in April 2026 with graph workflows, collaborative agent teams, and first-class multi-language support across Python, TypeScript, Java, Go, and Kotlin. Our three-way comparison of Google ADK vs OpenAI vs Claude Agent SDK covered the architecture and tradeoffs. This tutorial is the hands-on counterpart: we’re going to build a working multi-tool agent, from zero to a running web UI, in under 20 minutes.
By the end, you’ll have an agent that can fetch web pages, extract content, and answer questions with cited sources — all running locally against Gemini 2.5 Flash.
What We’re Building
A developer research assistant with three custom tools:
fetch_url— fetches a URL and returns the page content as textcount_tokens— counts tokens in a given text string (useful for context budgeting)get_current_time_utc— returns the current UTC timestamp (grounding the agent in real time)
The agent uses these tools autonomously: ask it to summarize a blog post, and it fetches the URL, extracts the content, and synthesizes an answer — all in one conversation turn.
Prerequisites
- Python 3.10 or later
- A Google AI Studio API key (free tier works — 1,500 requests/day with Gemini 2.5 Flash)
piporuvfor package management
We’re using Gemini 2.5 Flash as the default model because it’s free, fast, and ADK-native. But ADK is genuinely multi-model — you can swap in Claude via Vertex AI, Ollama for local models, or LiteLLM for any provider. Full model list in the ADK docs.
Step 1: Install ADK and Scaffold the Project
Install the google-adk package. At time of writing, the latest release is v2.5.0 (July 16, 2026).
pip install google-adk
Create the project directory. ADK uses a convention-over-configuration layout: each agent lives in its own folder with an __init__.py and an agent.py.
mkdir research-agent && cd research-agent
touch __init__.py agent.py
Set your API key. Create a .env file:
echo 'GOOGLE_API_KEY=your-api-key-here' > .env
Important: Add
.envto your.gitignoreimmediately. Committing API keys is the #1 way teams leak credentials into agent workflows.
Step 2: Write Your First ADK Agent
Open agent.py. Start with a minimal agent that has no tools — just to verify everything works:
from google.adk import Agent
root_agent = Agent(
name="research_agent",
model="gemini-2.5-flash",
instruction=(
"You are a helpful research assistant. "
"Answer questions clearly and concisely. "
"When you use tools, always cite the source of your information."
),
)
That’s the entire agent definition. root_agent is the entry point — ADK expects a module-level variable with that exact name. The model parameter accepts any model string from the ADK model registry. We’re using Gemini 2.5 Flash for speed.
Test it from the CLI:
adk run .
You’ll get an interactive prompt. Type "What is the difference between Python 3.12 and 3.13?" and the agent responds. It won’t use any tools yet — we haven’t defined them. Press Ctrl+C to exit.
Step 3: Add Custom Tools
ADK tools are plain Python functions. The agent discovers them automatically from the function signature and docstring — no decorator or registration ceremony needed in ADK 2.0.
Add these three tools to agent.py:
import datetime
import httpx
from google.adk import Agent
def fetch_url(url: str) -> str:
"""Fetch the content of a URL and return it as plain text.
Args:
url: The full URL to fetch, including https:// prefix.
Returns:
The page content as text, truncated to the first 8000 characters.
"""
try:
response = httpx.get(url, follow_redirects=True, timeout=10.0)
response.raise_for_status()
content = response.text
# Strip HTML tags crudely — production code should use BeautifulSoup
import re
text = re.sub(r"<[^>]+>", " ", content)
text = re.sub(r"\s+", " ", text).strip()
return text[:8000]
except Exception as e:
return f"Error fetching {url}: {str(e)}"
def count_tokens(text: str) -> str:
"""Estimate the number of tokens in a text string using a simple heuristic.
Args:
text: The text to count tokens for.
Returns:
A string with the estimated token count and character count.
"""
# Rough heuristic: ~4 characters per token for English text
estimated_tokens = len(text) // 4
return (
f"Estimated tokens: ~{estimated_tokens} "
f"(based on {len(text)} characters, ~4 chars/token)"
)
def get_current_time_utc() -> str:
"""Return the current UTC date and time in ISO 8601 format.
Returns:
The current UTC timestamp as an ISO 8601 string.
"""
return datetime.datetime.now(datetime.timezone.utc).isoformat()
root_agent = Agent(
name="research_agent",
model="gemini-2.5-flash",
instruction=(
"You are a helpful research assistant. "
"Answer questions clearly and concisely. "
"When you use tools, always cite the source of your information. "
"Use fetch_url to retrieve web content when the user asks about a specific URL or topic. "
"Use count_tokens when the user asks about text length or context size. "
"Use get_current_time_utc when the user asks about time or needs temporal context."
),
tools=[fetch_url, count_tokens, get_current_time_utc],
)
Three things to notice:
-
No decorator required. ADK 2.0 uses the function’s type hints and docstring to build the tool schema automatically. The
Args/Returnssections in the docstring become the tool description the model sees. -
httpxis not installed by default. Runpip install httpxbefore testing. For production, you’d also wantbeautifulsoup4for proper HTML parsing — we’re using a crude regex strip here for brevity. -
Tools return strings. ADK tools communicate results back to the model as plain strings. If you need structured data, serialize it to JSON and instruct the model to parse it in your agent instructions.
Step 4: Run the Agent with the Web UI
ADK ships a built-in web interface that’s genuinely useful for development — it shows tool calls, streaming responses, and session history.
adk web .
This starts a local server at http://localhost:8000. Open it and try these prompts:
"Summarize the content at https://adk.dev""How many tokens are in the sentence: 'The quick brown fox jumps over the lazy dog'?""What time is it right now in UTC?"
The web UI shows each tool invocation as it happens. When you ask to summarize a URL, you’ll see fetch_url fire, the content come back, and then the model synthesize a summary — all in one streaming response.
Step 5: Production Hardening (What We Skipped)
The agent above works, but it’s a prototype. Here’s what a production version needs:
Error Handling and Retries
ADK 2.0 workflows support built-in retry policies. When you graduate from a single agent to a graph workflow, you get retry configuration per node:
from google.adk import Workflow
workflow = Workflow(
name="research_workflow",
edges=[("START", root_agent)],
# Retry failed tool calls up to 3 times
default_retry_policy={"max_retries": 3, "backoff_factor": 2.0},
)
Authentication for Tools
If your agent calls authenticated APIs (GitHub, Jira, internal services), ADK supports tool authentication via OAuth2 and API key patterns. The tool context carries credentials automatically — no hardcoded tokens in agent code.
Callbacks for Guardrails
ADK’s callback system hooks into every stage of the agent lifecycle: before model calls, after tool execution, and before responses are sent. Use these for:
- Content filtering — block PII or sensitive data in tool responses
- Rate limiting — throttle expensive API calls
- Audit logging — record every tool invocation for compliance
MCP Tool Integration
ADK supports MCP tools natively. Any MCP-compatible server can be mounted as a tool source. This is how you connect to the broader AI tool ecosystem without writing custom adapter code:
from google.adk.tools import MCPToolset
mcp_tools = MCPToolset(
connection_params={
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
}
)
root_agent = Agent(
name="research_agent",
model="gemini-2.5-flash",
instruction="You are a helpful research assistant.",
tools=[fetch_url, count_tokens, get_current_time_utc, mcp_tools],
)
What’s Next
From here, the natural progression is:
- Multi-agent teams. ADK’s agent team tutorial shows how to compose specialized agents — a researcher, an analyst, a writer — into a coordinated pipeline.
- Graph workflows. Replace linear tool calls with deterministic execution graphs — branching, fan-out, human-in-the-loop approval steps.
- Deployment. ADK deploys to Cloud Run or GKE with a single command. The agent becomes an HTTP endpoint you can call from any application.
If you’re evaluating ADK against other SDKs, our Google ADK vs OpenAI vs Claude Agent SDK comparison breaks down where each framework wins — and where the lock-in lives.
Sources
- Google ADK Python GitHub Repository — official source, v2.5.0
- ADK Documentation — getting started, tools, deployment guides
- Google ADK PyPI — package releases and dependency info