Sitemap
Vengadesa Boopathi

Vengadesa Boopathi

Google ADK

9 min readMar 16, 2026

--

1. What is Google ADK?

Google ADK (Agent Development Kit) is an open-source, framework for building, testing, and deploying AI agents.

  • It provides a comprehensive set of libraries, tools, and conventions to create intelligent agents that can reason, use external tools, collaborate with other agents, and execute complex, multi-step tasks.
  • Model-agnostic: Works with Gemini, Anthropic, Meta, Mistral, and hundreds of other models via LiteLLM and Vertex AI Model Garden.
  • Supports both single and multi-agent systems: From simple chatbots to teams of specialized agents.

Announced at Google Cloud Next ’25 in April 2025, with stable Python v1.0.0 release in May 2025. It powers Google’s own Agentspace product.

2. Why Do We Need Google ADK?

  • Before ADK, developers often cobbled together solutions using general-purpose frameworks like LangChain, or built custom orchestration loops. Google ADK aims to standardize and simplify this process, providing a unified, production-ready toolkit.

3. How Google ADK Works: Architecture & Workflow

Press enter or click to view image in full size

WorkFlow of a Single Agent:

1. User Query: User sends a message to the agent via the Runner.
2. Session Initialization: Runner loads or creates a Session
(with history and state).
3. LLM Call: Runner sends the conversation (system prompt + history)
to the agent's LLM.
4. Action Decision: The LLM may respond with:
- A final answer (text).
- A request to call a tool (function call).
- A request to delegate to a sub‑agent.
5. Tool Execution: If a tool is requested, Runner executes the
corresponding function, passing arguments and ToolContext.
6. Loop: The result of the tool call is appended to the conversation;
Runner goes back to step 3.
7. Final Answer: When the LLM provides a final answer, Runner returns
it and updates the Session.

Multi-Agent WorkFlow

- Root Agent receives the user query.
- Based on its instructions, it may decide a sub‑agent is better suited.
- Root Agent calls the sub‑agent (via the Runner) with a specific request.
- Sub‑agent runs its own loop (LLM + tools) and returns a result.
- Root Agent incorporates the result and continues its loop, possibly
calling other sub‑agents.
- Orchestrators like SequentialAgent automate this: they run each agent
in order, automatically passing outputs.

3. Core Concepts

3.1 Agent :

An autonomous entity that uses an LLM to decide which actions to take to achieve a goal. Defined by a name, instruction (system prompt), model, tools, and optional sub‑agents.

weather_agent = Agent(
name="weather",
model="gemini-2.5-flash",
instruction="You provide weather info. Use the get_weather tool.",
tools=[get_weather] # assume get_weather exists
)

3.2. Tools and Integrations

Tool : A function or capability an agent can invoke. Can be pre‑built (e.g., google_search), custom (any Python function decorated with @tool), or connected via MCP.

Creating Custom Tools

from google.adk.tools import tool
@tool
def get_weather(city: str) -> str:
"""Get the current weather for a city.
Args:
city: The name of the city (e.g., "New York").
Returns:
A string describing the weather.
"""
# In reality, call a weather API
return f"The weather in {city} is sunny, 22°C."
  • Python function decorated with @tool , The docstring becomes the tool description seen by the LLM.
  • Type hints are used for argument validation.

Pre‑built Tools

- google_search: Performs a live Google Search.
- code_interpreter: Executes Python code in a secure sandbox.
- arxiv: Searches arXiv for academic papers.
- calculator: Evaluates mathematical expressions.
- webpage_fetcher: Fetches and reads content from a URL.

Example:
from google.adk.tools.weather import WeatherTool

# Create the prebuilt weather tool
weather_tool = WeatherTool()

# Create an agent and attach the tool
agent = Agent(
name="weather_agent",
instruction="You are a helpful assistant that provides current weather information.",
tools=[weather_tool],
)

MCP (Model Context Protocol) Tools

Connect to any MCP server to give your agent live data.

from google.adk.tools.mcp import MCPTool
mcp_tool = MCPTool(server_url="http://localhost:8000")
agent = Agent(…, tools=[mcp_tool])

3.3. Runner

The Runner is the execution engine. Think of it as the conductor that takes your agent and a user query, and runs the agent loop until a final answer is produced.

What the Runner Does

  • Takes a user query + session ID
  • Loads or creates a session to keep conversation context
  • Calls the agent’s LLM with system prompt, history, and state
  • Handles the LLM response:

Returns a final answer, or

Executes a tool call and adds the result to context, or

Delegates to a sub‑agent and feeds the result back

  • Repeats until a final answer is produced
  • Updates the session and returns the result (optionally streaming events)

Runner in Code

from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService

# Create a session service (stores sessions)
session_service = InMemorySessionService()
# Create a runner with your agent and the session service
runner = Runner(
agent=my_agent,
session_service=session_service
)
# Run a query
result = runner.run(
query="What's the weather in Paris?",
session_id="user-123"
)
print(result.content)

The Runner is stateless — it doesn’t store any data itself. All state is kept in the Session.

3.4. Session

The Session is the memory of a conversation. It holds everything that an agent needs to remember across multiple turns and between different agents in the same conversation.

A Session object has three main parts:

  • id — A unique identifier for the session
  • history — A list of messages exchanged so far.
  • state — A Python dictionary (JSON‑serializable)

Why Session is Important

  • Continuity: Without a session, each turn would be isolated. The agent wouldn’t remember what was said earlier.
  • Sharing data between agents:
  • Persistence: Sessions can be saved to a database (e.g., Firestore) and reloaded later, allowing conversations to resume even after the server restarts.

Session in Code

from google.adk.sessions import Session
# Creating a session manually
session = Session(
id="user-123",
user_id="user-123", # optional, for linking to a user
state={"notes": []}, # initial state
history=[] # empty history
)
# Accessing session data
print(session.state["notes"])
session.state["last_query"] = "weather in Paris"

Session Services

You don’t usually create Session objects directly. Instead, you use a Session Service that manages sessions for you.

  • InMemorySessionService — Stores sessions in memory (good for testing, but lost when the program ends).
  • FirestoreSessionService — Stores sessions in Google Cloud Firestore (persistent across restarts, suitable for production).

Accessing Session State in Tools

Tools receive a ToolContext object that includes the session state.

from google.adk.tools import tool, ToolContext
@tool
def save_note(content: str, context: ToolContext) -> str:
"""Save a note in the session."""
notes = context.state.get("notes", [])
notes.append(content)
context.state["notes"] = notes
return "Note saved."

3.5 Orchestration

Orchestration is about controlling the flow of multiple agents. While a single agent can handle many tasks, sometimes you need a team of agents working together — each with its own expertise. Orchestration defines how they interact.

Why Orchestration?

  • Divide and conquer: Break a complex task into smaller, specialised sub‑tasks.
  • Parallel processing: Run independent tasks simultaneously to speed up response.
  • Pipeline: Process data through a sequence of agents (like an assembly line).

Orchestration Agents in ADK

a) SequentialAgent

Get Vengadesa Boopathi’s stories in your inbox

Join Medium for free to get updates from this writer.

Runs a list of agents one after another. The output of the first becomes the input to the second, and so on.

from google.adk.agents import SequentialAgent
pipeline = SequentialAgent(
name="pipeline",
agents=[planner_agent, executor_agent, summarizer_agent]
)
# When you run pipeline, it will:
# 1. Run planner_agent with the original query.
# 2. Pass the output to executor_agent.
# 3. Pass that output to summarizer_agent.
# 4. Return the final output.

b) ParallelAgent

Runs multiple agents concurrently and then combines their results.

from google.adk.agents import ParallelAgent
parallel = ParallelAgent(
name="parallel_searches",
agents=[flight_agent, hotel_agent, car_rental_agent],
combiner=lambda outputs: "\n\n".join(outputs) # how to merge results
)

All three agents run at the same time. When all finish, their outputs are passed to the combiner function, which returns the final answer.

c) LoopAgent

Repeats a sub‑agent until a condition is met.

from google.adk.agents import LoopAgent
refinement_loop = LoopAgent(
name="refiner",
agent=generator_agent,
max_iterations=5,
stop_condition=lambda output: "FINAL" in output
)

The generator runs repeatedly; each time its output is fed back as input. The loop stops when the output contains the word “FINAL” or after 5 iterations.

d) Hierarchical Delegation (Implicit Orchestration)

Even without explicit orchestrators, a parent agent with sub_agents can delegate tasks. The parent’s LLM decides when to call a sub‑agent based on the sub‑agent’s description. This is a form of dynamic orchestration.

math_agent = Agent(
name="math_expert",
instruction="Solve math problems.",
description="Useful for mathematical tasks."
)
root_agent = Agent(
name="root",
instruction="Delegate math tasks to math_expert.",
sub_agents=[math_agent]
)

When you run root_agent, if the LLM determines the task is mathematical, it will output a special delegate action, and the Runner will invoke math_agent automatically.

How Orchestration Relates to Runner and Session

  • The Runner executes every agent, whether it’s a simple agent or an orchestrator.
  • The Session is shared among all agents involved. So state written by one agent is visible to others.
  • Orchestrators themselves are just agents — they have instructions, and they use the Runner to invoke their sub‑agents.

For example, when you run a SequentialAgent, its own run method (called by the Runner) will create a new Runner instance for each sub‑agent, passing the same session, so the sub‑agents see the accumulated context.

4. Evaluation and Debugging

Evaluation

1. Create test cases in YAML/JSON:

- input: "What is 2+2?"
expected_output: "4"
- input: "Search for AI news"
expected_tool_calls:
- tool_name: google_search
arguments:
query: "AI news"
expected_output_contains: "artificial intelligence"

2. Run evaluation:

adk eval - agent my_agent.py - tests tests/test_cases.yaml

3. Use in code:

from google.adk.evaluation import Evaluator
evaluator = Evaluator(agent=my_agent, test_cases=test_cases)
results = evaluator.run()
print(results.summary())

Debugging

  • adk run my_agent.py: Interactive terminal session with detailed logs.
  • adk web my_agent.py: Launches a web UI at http://localhost:8000 for step‑by‑step debugging.

5. Deployment Options

Local / Embedded

Embed the Runner in any Python application (e.g., Flask API).

from flask import Flask, request
from google.adk.runners import Runner
from my_agent import root_agent
app = Flask(__name__)
runner = Runner(agent=root_agent)
@app.route("/chat", methods=["POST"])
def chat():
data = request.json
result = runner.run(data["query"], session_id=data["session_id"])
return {"response": result.content}

Containerized Deployment

1. Create a Dockerfile:

FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]

2. Build and run the container, then deploy to any container platform (Cloud Run, Kubernetes, etc.).

Vertex AI Agent Engine (Managed)

Google Cloud’s fully managed service for agents. Provides auto‑scaling, monitoring, and security.

To deploy:

1. Package your agent with a main.py containing a create_agent() function:

# main.py
from google.adk.agents import Agent
def create_agent():
return Agent(name="my_agent", …)

2. Use the gcloud CLI:

gcloud alpha vertex ai agent-engine create \
- display-name="my-agent" \
- agent-engine-config-file=config.yaml

6. Comparison with Other Frameworks

Press enter or click to view image in full size

Key Differentiators of ADK:

  • Enterprise readiness: Built‑in evaluation, seamless Google Cloud deployment, enterprise connectors.
  • A2A support: Future‑proofing for multi‑framework agent ecosystems.

7. Agent2Agent (A2A) Protocol

  • Open standard for inter‑agent communication.
  • ADK agents can collaborate with agents from other frameworks (e.g., LangChain, AutoGen) if they implement A2A.
from google.adk.a2a import A2AClient
client = A2AClient(agent_url="http://other-agent:8000/a2a")
response = client.send_message("Hello", session_id="cross")

8. Libraries and Conventions Explained

Libraries (Modules)

Module What It Provides
google.adk.agents Base classes for agents: Agent, LlmAgent, SequentialAgent, ParallelAgent, LoopAgent.
google.adk.tools @tool decorator, pre‑built tools, ToolContext, MCP integration.
google.adk.runners Runner class for executing agents.
google.adk.sessions Session, InMemorySessionService, FirestoreSessionService, base classes.
google.adk.orchestration Higher‑level orchestration helpers (the orchestrator agents).
google.adk.evaluation Evaluator class and supporting functions.
google.adk.integrations Connectors for LiteLLM, Vertex AI, MCP.
google.adk.code_executor Sandboxed environment for code_interpreter.
google.adk.artifacts Support for handling files (e.g., images, PDFs) generated by agents.
google.adk.a2a Client and server support for the Agent2Agent protocol.

Conventions (Best Practices)

  • Agent definition: Each agent has name, instruction (system prompt), model, optional tools, optional sub_agents. Sub‑agents include a description for delegation decisions.
  • Tool documentation: Write clear docstrings with parameter descriptions; use type hints.
  • State management: Use session state to share data; tools should write results to state; orchestrators may pass outputs explicitly.

9. Starting a Project with Google ADK

Installation

python -m venv adk-env
source adk-env/bin/activate # Windows: adk-env\Scripts\activate
pip install google-adk

Project Structure (No Automatic Scaffolding) :

my-adk-project/
├── .venv/
├── agents/
│ ├── __init__.py
│ ├── customer_support.py
│ └── research_assistant.py
├── tools/
│ ├── __init__.py
│ ├── weather.py
│ └── database.py
├── tests/
│ ├── test_cases.yaml
├── config/
├── main.py
├── requirements.txt
└── README.md

Complete Example Combining Components

# my_project/main.py
from google.adk.agents import Agent, SequentialAgent
from google.adk.tools import google_search, tool
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService

# 1. Custom tool
@tool
def get_time(city: str) -> str:
"""Get the current time in a city."""
# In reality, call a time API
return f"The current time in {city} is 12:00 PM."

# 2. Sub‑agents
weather_agent = Agent(
name="weather",
model="gemini-2.5-flash",
instruction="You provide weather info. Use the get_weather tool.",
tools=[get_weather] # assume get_weather exists
)
time_agent = Agent(
name="time",
model="gemini-2.5-flash",
instruction="You provide time info. Use the get_time tool.",
tools=[get_time]
)
# 3. Root agent with sub‑agents
root = Agent(
name="root",
model="gemini-2.5-flash",
instruction="Delegate weather questions to weather, time questions to time.",
sub_agents=[weather_agent, time_agent]
)
# 4. Runner and session
session_service = InMemorySessionService()
runner = Runner(agent=root, session_service=session_service)
# 5. Run
result = runner.run("What's the weather in Paris?", session_id="test")
print(result.content)

10. CLI Commands

  • adk run <file> — Interactive terminal.
  • adk web <file> — Web debugger.
  • adk eval — agent <file> — tests <file> — Run evaluation.

--

--