BUILD · 5 MIN READ

Build with Google’s Agent Development Kit

Define a root agent and a Python function tool, then run it with ADK.

Download example files Code + setup + checks in a ZIP
Jump to a section 9 sections

EXAMPLE USE CASE

Create an ADK order-support project

You want an agent that the ADK development runner can discover and invoke with a function tool.

Input
A sample_agent Python package exposing root_agent and a question about A104.
Expected output
A Gemini response grounded in lookup_order and the packed fixture.
  • Success check: Run adk from the package parent, inspect the tool event, then test a missing identifier.
  • Try a failure: A missing __init__.py or root_agent must be diagnosed as project discovery, not a model failure.

Example scope: A real Google ADK integration. Session storage and user authorization must be supplied separately.

Google ADK exampleGiskard example
SEE HOW THE SYSTEM FITS TOGETHERSELECT A COMPONENT
taskinvokedecisionvalidatedobservationstatecompleteApplication requestIdentity + goalGoogle’s AgentDevelopment KitAgent or graph runtimeConfigured modelAvailable provider modelAllowed toolsTyped application functionsState + limitsMessages and stopping rulesVerified answerCompare with the result
  1. Resolve the real user and pass a bounded task to the SDK.

  2. The runtime manages the loop or explicit state transitions; it does not replace resource authorization.

  3. Keep provider credentials on the server and select a model supported by the API account.

  4. The example exposes a local fixture. A real tool must check the authenticated user and resource.

  5. Track the current conversation and stop when the turn or recursion budget is reached.

    Result or stopping point
  6. For A104, confirm that the answer reflects the lookup observation and contains no invented dates.

    Result or stopping point
Google’s Agent Development Kit

The runtime manages the loop or explicit state transitions; it does not replace resource authorization.

Follow the arrows, then select a component to inspect its responsibility. On mobile, downward arrows connect the next step; bent arrows identify branches and return paths. Select a destination to jump to that component.

Where it fits

  • Google ADK provides agent definitions, function tools, and application workflow building blocks.
  • An agent project exposes a root_agent that the development runner can load.

Prepare the project

  • Install google-adk.
  • Create sample_agent/__init__.py containing from . import agent, and save the example as sample_agent/agent.py.
  • Set GOOGLE_API_KEY and GOOGLE_MODEL to an available Gemini model.
  • Run adk run sample_agent from the parent directory.
Shell · install in a virtual environment
python3 -m venv .venv
source .venv/bin/activate
python -m pip install google-adk
export GOOGLE_API_KEY="your-api-key"
export GOOGLE_GENAI_USE_VERTEXAI=FALSE
export GOOGLE_MODEL="your-enabled-gemini-model-id"
mkdir -p sample_agent
printf "from . import agent\n" > sample_agent/__init__.py
Python · sample_agent/agent.py
import os
from google.adk.agents.llm_agent import Agent

def lookup_order(order_id: str) -> str:
    """Read an order status from a local demonstration fixture."""
    orders = {"A104": "Packed; awaiting courier pickup"}
    return orders.get(order_id, "Order not found")

root_agent = Agent(
    name="order_assistant",
    model=os.environ["GOOGLE_MODEL"],
    description="Answers status questions using sample order data.",
    instruction=(
        "Use lookup_order for order status. "
        "Report only the returned information."
    ),
    tools=[lookup_order],
)

Educational example. Uses your configured environment and credentials; no paid model call is made by this website.

Try the task

  • Ask “What is the status of A104?” The tool returns sample data.
  • Inspect whether the answer reflects that result, then ask about an unknown order and check that the agent does not invent a status.

Keep state and tools distinct

  • As the application grows, decide which information belongs to the current session and which should persist across sessions.
  • The tool service must enforce access independently of the agent’s instructions.

Run and verify

Shell
adk run sample_agent
# Then enter: What is the status of A104?
  • Run adk from the parent of sample_agent so the package can be discovered.
  • The root_agent calls lookup_order and answers from the A104 fixture.

Troubleshooting and failure tests

  • Agent discovery errors usually mean the package is missing __init__.py or root_agent.
  • Do not mix a Gemini API-key setup with Vertex AI project and location credentials unintentionally.

Before production

  • Replace the local fixture with a service that enforces authenticated tenant and resource permissions.
  • Add timeouts, bounded retries, tracing redaction, and a regression case for each observed failure.
  • Model calls consume provider API usage when you run this example; this website only displays the code.

Keep exploring

A voice agent with Google Gemini LiveA layered architecture for agent memory