#4551 Google Agent Development Kit (ADK)
#4551 Google Agent Development Kit (ADK)
#4551 From simple to more complex, explain Google Gemini Agent Development Kit (ADK)
The Google Gemini Agent Development Kit (ADK) is an open-source development framework designed to let you build, test, and scale AI-driven applications.
1. The Simple Level: The Core Brain
At its most basic level, an agent is an AI with a specific personality and job description.
The Agent: The "brain" powered by Gemini.
You define its mission through system instructions (e.g., "You are a helpful travel planner"). The Session: The agent's memory.
It saves the ongoing conversation so the AI remembers what you said three turns ago. The Runner: The engine that executes everything.
It takes your question, gives it to the Agent, reads the Session history, and produces the output.
Example: You ask the agent to plan a 3-day trip. On the next turn, you say, "I don't like museums." Because of the Session memory, the agent seamlessly updates the itinerary without forcing you to re-explain the whole trip.
2. The Intermediate Level: Giving the Agent Tools
An agent relying only on its internal knowledge eventually hits a wall.
You can give an agent three types of tools:
Built-in Tools: Google Search or Code Execution.
Custom Tools: Python or Java functions you write yourself (e.g., fetching internal company data or calculating a specific currency exchange rate).
Third-Party Tools: Integrations with community tools (like LangChain or Model Garden).
Example: When you ask, "What is the weather in Tokyo right now?", the agent recognizes it doesn't know, dynamically calls a
get_weather()API tool, looks at the live data, and gives you the answer.
3. The Complex Level: Multi-Agent Systems & Graph Workflows
When a task is too massive or complex for a single AI brain to handle, ADK scales into an enterprise-grade orchestration framework.
Multi-Agent Teams: You can create a hierarchy where a "Coordinator Agent" receives a massive request and delegates sub-tasks to specialized sub-agents (e.g., a Researcher Agent, a Writer Agent, and a Legal Compliance Agent).
Graph-Based Workflows: Instead of letting the AI blindly guess what to do next, you can write deterministic Python/Java code to control the execution flow. You design nodes, parallel tasks, and conditional logic.
Human-in-the-Loop: For sensitive operations (like approving a financial refund), ADK supports durable, asynchronous checkpoints. The agent pauses its work, waits for a human manager to click "Approve," and then resumes where it left off.
Why Developers Use It
ADK is built to bridge the gap between quick AI prototypes and heavy-duty corporate software. It integrates natively with Google Cloud’s Vertex AI Agent Platform, meaning once you build a smart agent locally on your laptop, you can immediately deploy it into a secure, scalable production environment.
Are you looking to build a basic personal assistant tool, or are you architecting a more rigid, multi-step business workflow?
Provide five example python workflows in increasing capability
Here is a progression of five Python workflows using the Google Gemini Agent Development Kit (ADK), scaling from a basic single agent to a complex enterprise pipeline.
Workflow 1: The Basic Conversational Agent (Entry Level)
This script sets up a simple, single-purpose agent. It configures the brain (Agent) and passes a user prompt to it via a runner session.
from google.adk.agents import LlmAgent
# 1. Define the agent and its core instruction
support_agent = LlmAgent(
name="customer_support",
model="gemini-flash-latest",
instruction="You are a polite retail support agent. Keep answers under 2 sentences."
)
# 2. Run an interaction (the framework handles session memory automatically)
response = support_agent.generate("Hi, I want to know if you ship to Canada?")
print(response.text)
Workflow 2: Grounding with Built-in Tools (Intermediate Level)
This workflow elevates the agent from relying purely on training data to pulling live, real-world facts using Google's built-in tools.
from google.adk.agents import LlmAgent
from google.adk.tools import google_search
researcher_agent = LlmAgent(
name="news_researcher",
model="gemini-flash-latest",
instruction="You synthesize current events accurately.",
tools=[google_search] # Injects live Google Search capability
)
# The agent autonomously determines when to use the tool based on the prompt
response = researcher_agent.generate("What were the major tech updates announced yesterday?")
print(response.text)
Workflow 3: Custom API Tool Integration (Advanced Level)
In this scenario, you write a Python function, and the ADK transforms it into an executable tool.
from google.adk.agents import LlmAgent
# 1. Define a custom local python function
def check_inventory(item_id: str) -> str:
"""Checks warehouse stock levels for a given item ID."""
# Mock database call
database = {"SKU-123": "12 units available", "SKU-999": "Out of stock"}
return database.get(item_id, "Item ID not found")
# 2. Give the function to the agent as a tool
inventory_agent = LlmAgent(
name="inventory_manager",
model="gemini-flash-latest",
instruction="Help staff track warehouse data. Always use the inventory tool for SKUs.",
tools=[check_inventory]
)
response = inventory_agent.generate("Hey, can you see if we have any stock left for SKU-123?")
print(response.text)
Workflow 4: Multi-Agent Collaboration (Expert Level)
This workflow handles multi-agent orchestration. A sequential team structure routes a raw request through multiple specialized entities.
from google.adk.agents import LlmAgent, SequentialAgent
# Agent 1: The Researcher
writer = LlmAgent(
name="copywriter",
model="gemini-flash-latest",
instruction="Write a catchy product description based on provided technical specifications."
)
# Agent 2: The Legal/Compliance Auditor
legal_reviewer = LlmAgent(
name="legal_compliance",
model="gemini-flash-latest",
instruction="Review marketing copy. Flag absolute claims like 'the best' or 'guaranteed' as compliance risks."
)
# Orchestrate them to run back-to-back
marketing_pipeline = SequentialAgent(
name="marketing_pipeline",
agents=[writer, legal_reviewer]
)
result = marketing_pipeline.generate("Specs: UltraBook Pro. 24hr battery. Made of recycled aluminum.")
print(result.text)
Workflow 5: Graph Workflows with Human-in-the-Loop (Enterprise Level)
ADK 2.0 introduces Graph Workflows.
from google.adk.workflows import WorkflowGraph, Node
from google.adk.agents import LlmAgent
# Define agents and systems
triage_agent = LlmAgent(name="triage", model="gemini-flash-latest", instruction="Determine risk.")
def process_refund(amount: float):
return f"Successfully refunded ${amount}"
# Create a Graph Workflow
workflow = WorkflowGraph(name="refund_pipeline")
# Node A: AI Triage
@workflow.node()
def assess_request(state):
ai_response = triage_agent.generate(f"Assess fraud risk for amount: {state['amount']}")
state['risk'] = "HIGH" if "risk" in ai_response.text.lower() else "LOW"
return state
# Node B: Conditional Routing
@workflow.node()
def route_approval(state):
if state['risk'] == "HIGH":
# Pause execution and wait for human input via the Cloud Console/API
workflow.wait_for_human_approval(reason="High risk transaction over limit.")
return state
# Node C: Deterministic Action Execution
@workflow.node()
def finalize_transaction(state):
receipt = process_refund(state['amount'])
state['status'] = "Complete"
return state
# Chain the nodes together structurally
workflow.add_edge(assess_request, route_approval)
workflow.add_edge(route_approval, finalize_transaction)
# Execute the workflow programmatically
current_run = workflow.run(initial_state={"amount": 1500.00})
Which of these structural patterns aligns closest with the project you are planning to build next?
When using this ADK, how can I build up a library of agents and tools for later use?
When building at scale with the Gemini Agent Development Kit (ADK), you don't want to constantly redefine your agents and tools in every individual script.
To build a reusable library, you have two primary options: The Local Open-Source Approach (organizing code locally into reusable components) and The Enterprise Approach (using Google Cloud’s Agent Registry).
Approach 1: The Local Approach (The "Skills" & Code-First Pattern)
ADK uses standard Python decorators and modular objects, meaning you can organize your library exactly like a traditional Python package.
1. Build a Centralized Tool Inventory (my_library/tools.py)
In ADK, any function with proper type hints and a descriptive docstring can be exported as a tool.
# my_library/tools.py
from google.adk.tools import tool
@tool
def get_stock_level(sku: str) -> int:
"""Retrieves live warehouse metrics for a specific item identifier."""
return 42 # standard integration logic
@tool
def process_payment(amount: float) -> bool:
"""Executes a financial ledger charge."""
return True
2. Build an Agent Template Factory (my_library/agents.py)
Instead of hardcoding agents, write functions or classes that dynamically return pre-configured agents pre-loaded with specific toolsets.
# my_library/agents.py
from google.adk.agents import LlmAgent
from .tools import get_stock_level
def create_logistics_agent() -> LlmAgent:
"""Returns a standardized supply chain assistant."""
return LlmAgent(
name="logistics_expert",
model="gemini-flash-latest",
instruction="You are a logistics specialist. Always check inventory tools before answering.",
tools=[get_stock_level]
)
3. Use Them Anywhere
Now, your main workflows just import these elements like any standard utility library:
from my_library.agents import create_logistics_agent
# Pull from your library instantly
shipping_bot = create_logistics_agent()
print(shipping_bot.generate("Do we have enough SKU-456 in stock?").text)
Approach 2: The Enterprise Cloud Approach (Google Agent Registry)
For distributed teams or microservice architectures, Google Cloud provides Agent Registry directly integrated into the ADK ecosystem.
Instead of passing Python modules around, you register agents and MCP (Model Context Protocol) tools directly to a secure, centralized cloud hub where any team member or separate microservice can discover them.
1. Register and Query Components Cloud-Side
By initializing an AgentRegistry client, you can catalog your assets globally across Google Cloud.
import os
from google.adk.integrations.agent_registry.agent_registry import AgentRegistry
# Initialize targeting your cloud project location
registry = AgentRegistry(
project_id=os.environ.get("GOOGLE_CLOUD_PROJECT"),
location="us-central1"
)
# Fetch a pre-configured agent managed centrally by your organization
enterprise_legal_agent = registry.get_agent("agentregistry-1234-abcd")
# Fetch an entire toolkit/MCP server managed by another team
finance_tool_server = registry.get_mcp_server("agentregistry-5678-efgh")
2. Dynamically Load Domain Expertise ("Skills")
ADK features a SkillToolset architecture.agentskills.io standard.
Agents linked to the Agent Registry can look up and load these skills on-demand dynamically at runtime only when a user asks a highly specialized question.
Which fits your project?
Use Approach 1 (Local/Monorepo) if you are building an independent application, a startup prototype, or a clean single-repository Python project.
Use Approach 2 (Agent Registry) if you are building an enterprise platform where multiple independent backends, microservices, or distinct teams need to share the same security-compliant tools and agents.
From <https://gemini.google.com/app/> Google Gemini (3.5 Flash)
Comments
Post a Comment