19 Google ADK Tutorial

 Google ADK Tutorial

1️ What is Google ADK?

Simple explanation:
Google ADK (Agent Development Kit) is a framework to build smart AI agents that can:

  • Work together (multi-agent systems)
  • Call tools or APIs (like databases, web services)
  • Evaluate their own outputs
  • Be deployed into production easily

Why use it:

  • Easier to scale complex tasks
  • Modular: break jobs into smaller specialized agents
  • Built-in evaluation avoids hallucinations

 

 



 

 

 


2️ Core Concepts

Concept

Simple Explanation

Agent

A single AI “worker” that can perform a task

Multi-Agent System

Multiple agents working together on one problem

Orchestrator

Brain that tells agents when to act and in what order

Tools / MCP

External functions your agent can call (like a skill database or API)

Evaluation

Built-in scoring to check if the output is correct

Deployment

Turning your system into an API or cloud service


3️ Project Overview: Resume Analyzer

Goal: Score a resume against a job description and suggest improvements

Agents Involved:

  1. Planner Agent → Breaks down tasks
  2. Resume Parser Agent → Extracts skills, experience
  3. Job Analyzer Agent → Extracts job requirements
  4. Matching Agent → Compares resume to job
  5. Improvement Agent → Suggests resume edits
  6. Critic Agent → Checks and refines outputs

4️ Diagram: Multi-Agent Flow


            

Simple explanation:

  • The planner breaks tasks → parsing and analyzing run in parallel → matching and improving → critic validates → user gets output

5️ Code Overview (Concise)

Step 1: Install ADK

pip install google-adk

Step 2: Define Agents

from adk import Agent

planner = Agent(name="planner", role="Break tasks into steps")
resume_parser = Agent(name="resume_parser", role="Extract resume data")
job_analyzer = Agent(name="job_analyzer", role="Extract job requirements")
matcher = Agent(name="matcher", role="Compare resume to job")
improver = Agent(name="improver", role="Suggest improvements")
critic = Agent(name="critic", role="Validate output")

Step 3: Orchestrate Agents

from adk import Orchestrator

orchestrator = Orchestrator(
    agents=[planner, resume_parser, job_analyzer, matcher, improver, critic],
    flow=[
        ("planner", "plan task"),
        ("resume_parser", "extract resume"),
        ("job_analyzer", "extract job"),
        ("matcher", "compare"),
        ("improver", "suggest improvements"),
        ("critic", "validate output")
    ]
)

result = orchestrator.run({"resume": "...", "job_description": "..."})
print(result)

Step 4: Add External Tools (Optional)

from adk.tools import MCPTool

skills_tool = MCPTool(name="skills_lookup", endpoint="http://localhost:4000/skills")
matcher.add_tool(skills_tool)

Simple explanation:

  • Tools help agents fetch extra info (like skill databases)
  • MCP = “plug-and-play” standard for connecting external functions

Step 5: Evaluate Output

from adk.evals import Evaluator

evaluator = Evaluator(metrics=["accuracy", "relevance"])
score = evaluator.evaluate(agent=matcher, input="Compare resume to job", expected_output="High match")
print(score)

Simple explanation:

  • Built-in evaluation ensures your agents don’t hallucinate or miss key info

Step 6: Deploy Agent

from adk.deploy import serve

serve(orchestrator, port=8080)  # Turn your system into a web API

Simple explanation:

  • Deployment = your agents become a service that can be called by users or apps
  • Can scale on Google Cloud, Vertex AI, Cloud Run

6️ Learning Roadmap (Concise)

Level

Focus

Projects

Beginner

LLM basics, prompt engineering

Chatbot agent

Intermediate

Multi-agent systems, basic tools

Resume analyzer (this project)

Advanced

MCP tools, evaluation, orchestration patterns

Autonomous workflow agents

Expert

Cloud deployment, observability

IT automation agent, cloud optimization agent


7️ Comparison With Other Frameworks

Feature

Google ADK

LangChain

AutoGen

Multi-agent

Native

Add-on

Strong

Tool Integration

MCP Tools

External

Evaluation

Built-in

External

External

Deployment

Native


Summary (Simple Terms)

  1. Break tasks into agents
  2. Use orchestrator to manage flow
  3. Integrate tools to enhance capability
  4. Evaluate results to avoid errors
  5. Deploy to cloud or API

 

 

 

 

Developing Agents with Google ADK

Multi-Agent Architecture, Orchestration, Tools, Evaluation & Colab Setup

A practical developer guide

What is Google ADK?

Google Agent Development Kit (ADK) is an open-source, code-first framework introduced at Google Cloud NEXT 2025, designed to simplify full-stack development of agents and multi-agent systems. It powers agents inside Google products like Agentspace and the Google Customer Engagement Suite.

ADK is model-agnostic (Gemini, Anthropic, Mistral, and more via LiteLLM), deployment-agnostic, and available in Python, Java, and TypeScript.

 

Key capabilities at a glance:

         Multi-agent hierarchies with intelligent routing and delegation

         Workflow orchestration: Sequential, Parallel, and Loop patterns

         Rich tool ecosystem: pre-built tools, MCP tools, LangChain/LlamaIndex integrations

         Built-in evaluation to test response quality and execution trajectories

         Deploy anywhere: Vertex AI Agent Engine, Cloud Run, or Docker

 

Agent Types

ADK provides three main agent categories that can be combined to build sophisticated systems:

 

Type

Role

Best for

LlmAgent

Reasons, plans, routes tasks using an LLM

Flexible, language-centric tasks

WorkflowAgent

Orchestrates flow deterministically (no LLM for routing)

Structured pipelines needing predictable execution

CustomAgent

Extend BaseAgent with your own logic

Unique integrations or control flow

 

Your First Agent

Install ADK and define a simple agent with a custom tool:

 

pip install google-adk

 

from google.adk.agents import LlmAgent

 

def get_weather(city: str) -> str:

    """Returns current weather for a given city."""

    return f"Sunny, 22 degrees in {city}"

 

agent = LlmAgent(

    name="WeatherAgent",

    model="gemini-2.5-flash",

    description="Answers weather questions.",

    tools=[get_weather],

)

 

ADK reads the function's docstring to understand when and how to invoke the tool. Keep docstrings clear and descriptive.

 

Multi-Agent Architecture

ADK organizes agents into a hierarchy — like a company org chart. The root agent is the coordinator; sub-agents are specialists. Each agent has exactly one parent, ensuring a clear chain of delegation.

 

greeter = LlmAgent(

    name="Greeter",

    model="gemini-2.5-flash",

    description="Handles greetings only.",

)

 

coordinator = LlmAgent(

    name="Coordinator",

    model="gemini-2.5-flash",

    description="Routes queries to the right specialist.",

    sub_agents=[greeter, weather_agent],

)

 

When a user says 'Hi', the coordinator sees the Greeter's description and delegates automatically. 'What's the weather in Tokyo?' stays with the WeatherAgent.

 

Workflow Orchestration

Workflow agents control execution flow deterministically — no LLM involved in routing decisions.

 

SequentialAgent

Runs sub-agents in order — Step A, then B, then C. Ideal for document processing pipelines.

from google.adk.agents import SequentialAgent

 

pipeline = SequentialAgent(

    name="DocPipeline",

    sub_agents=[parser_agent, extractor_agent, summarizer_agent],

)

 

ParallelAgent

Runs sub-agents concurrently. Use when tasks are independent — e.g. searching flights and hotels simultaneously. Note: sub-agents share session state, so write to unique keys.

from google.adk.agents import ParallelAgent

 

parallel = ParallelAgent(

    name="TravelSearch",

    sub_agents=[flight_agent, hotel_agent],

)

 

LoopAgent

Repeats a sequence until a quality gate passes. Perfect for generate-then-validate patterns (e.g. code generation with syntax checking).

from google.adk.agents import LoopAgent, SequentialAgent

 

quality_loop = LoopAgent(

    name="QualityGate",

    sub_agents=[

        SequentialAgent(sub_agents=[generator_agent, critic_agent])

    ],

)

 

Tool Ecosystem

ADK agents can use a wide range of tools:

         Pre-built tools: Google Search, Code Execution

         Custom Python functions (docstring = tool description)

         MCP (Model Context Protocol) tools

         Third-party libraries: LangChain, LlamaIndex

         Other agents as tools (LangGraph, CrewAI)

 

Using MCP tools:

from google.adk.tools.mcp_tool import MCPToolset

 

tools = MCPToolset.from_server('my-mcp-server-url')

agent = LlmAgent(name='MCPAgent', model='gemini-2.5-flash', tools=tools)

 

Built-in Evaluation

ADK's evaluation tools let you test both response quality and step-by-step execution trajectories against predefined datasets.

 

Run evaluations from the command line:

adk eval my_agent/ my_agent/eval_set_001.evalset.json

 

Your eval set (JSON) specifies input, expected output, and optionally expected tool calls — so you can verify not just the final answer but the reasoning path.

 

The dev UI (adk web) provides a browser-based debugger for live interaction, session inspection, and tracing during local development.

 

Deployment Options

ADK agents can be deployed anywhere:

         Vertex AI Agent Engine — fully managed, auto-scaled (recommended)

         Cloud Run or Docker — containerize for custom infrastructure

         Local machine — for development and testing

 

Deploying to Vertex AI Agent Engine:

import vertexai

from vertexai import agent_engines

 

vertexai.init(project='my-project', location='us-central1')

agent_engines.deploy(agent=coordinator)

 

Running ADK on Google Colab

Google Colab is a convenient environment for prototyping ADK agents. Here is everything you need to get started.

 

Setup cell (run first)

!pip install google-adk -q

 

# For non-Gemini models (e.g. Claude via LiteLLM)

!pip install litellm -q

 

API key setup

Store your key in Colab Secrets (the lock icon in the left sidebar), then access it like this:

import os

from google.colab import userdata

 

os.environ['GOOGLE_API_KEY'] = userdata.get('GOOGLE_API_KEY')

 

# If using Anthropic models via LiteLLM:

# os.environ['ANTHROPIC_API_KEY'] = userdata.get('ANTHROPIC_API_KEY')

 

Running your agent

Use the Runner and InMemorySessionService to interact with agents in Colab:

from google.adk.agents import LlmAgent

from google.adk.runners import Runner

from google.adk.sessions import InMemorySessionService

from google.genai import types

 

def get_weather(city: str) -> str:

    """Returns current weather for a given city."""

    return f"Sunny, 22 degrees in {city}"

 

agent = LlmAgent(

    name="WeatherAgent",

    model="gemini-2.5-flash",

    description="Answers weather questions.",

    tools=[get_weather],

)

 

session_service = InMemorySessionService()

session = session_service.create_session(app_name="demo", user_id="user1")

runner = Runner(agent=agent, app_name="demo", session_service=session_service)

 

async def ask(question: str):

    content = types.Content(role='user', parts=[types.Part(text=question)])

    async for event in runner.run_async(

        user_id='user1',

        session_id=session.id,

        new_message=content

    ):

        if event.is_final_response():

            print(event.response.text)

 

# In Colab, await works directly at cell level:

await ask('What is the weather in Tokyo?')

 

Colab-specific notes

         await works at the top level. Colab cells run in an async context — no need to wrap in asyncio.run() (which would error).

         adk web (dev UI) does not work in Colab. Use the Runner + run_async pattern above instead. Print event objects in the loop to inspect tool calls and intermediate steps.

         Use Secrets, not plain text. Colab's built-in Secrets manager keeps keys out of notebook history and persists them across sessions.

         Multi-agent, evaluation, and shell commands all work fine. SequentialAgent, ParallelAgent, LoopAgent, and adk eval (via !adk eval ...) run normally in Colab.

 

Key Mental Model

Rather than one monolithic agent trying to do everything, ADK encourages a team of focused specialist agents — each with clear instructions for a single job. This delivers higher fidelity, better control, and true scalability.

Think of it like microservices, but for AI reasoning: if your agent fails, you shouldn't have to tear down the entire prompt to find the bug. Reliability comes from decentralization and specialization.

 

ADK is the same framework powering agents inside Google Agentspace and the Google Customer Engagement Suite — so it's production-tested at scale.

 

Resources

         Documentation: google.github.io/adk-docs

         Python SDK: github.com/google/adk-python

         TypeScript SDK: github.com/google/adk-js

         Samples: github.com/google/adk-samples

         Vertex AI Agent Engine: cloud.google.com/agent-builder

 

Comments

Popular posts from this blog

15 Agent AI vs Agentic AI

16 Build a Free Chat App on Google Colab using RAG