Runnable Examples¶
adk-fluent ships with 49 standalone examples you can run directly with
adk web. Each example is a self-contained agent (or multi-agent system)
in its own directory under examples/.
Copy-paste-run contract¶
Every example in this project follows a contract:
Interactive examples (
examples/<name>/agent.py): copy the directory, runadk web <name>, and it works. The only prerequisites are installing the package and setting up your.envfile (see below).Cookbook examples (
examples/cookbook/NN_name.py): these are equivalence tests, not standalone scripts. They prove that fluent builders produce identical ADK objects to native code. Run them withpytest examples/cookbook/ -v— no API key needed, no network calls.
If any example fails to meet this contract, please file an issue.
Prerequisites¶
Before running any interactive example, complete this one-time setup:
1. Install the package with example dependencies:
pip install adk-fluent[examples]
This installs adk-fluent, google-adk, and python-dotenv.
2. Set up Google Cloud / Vertex AI credentials:
cp examples/.env.example examples/.env
Edit examples/.env and fill in:
# Required: your Google Cloud project ID
GOOGLE_CLOUD_PROJECT=your-project-id
# Required: Vertex AI region
GOOGLE_CLOUD_LOCATION=us-central1
# Required: enable Vertex AI backend
GOOGLE_GENAI_USE_VERTEXAI=TRUE
You also need gcloud authenticated:
gcloud auth application-default login
3. Verify your setup works:
cd examples
adk web simple_agent
If the web UI opens and the agent responds, you are ready.
How to run¶
cd examples
# Interactive web UI
adk web simple_agent
# Headless CLI mode
adk run simple_agent
# Run all cookbook equivalence tests (no API key needed)
pytest cookbook/ -v
Example directory¶
Each example folder contains:
agent.py— The agent definition (exportsroot_agent)__init__.py— Package markerOptional:
prompt.py,tools.py— Helper modules for complex examples
Simple examples¶
Standalone agents demonstrating individual features.
Example |
Description |
Prerequisites |
Run command |
|---|---|---|---|
|
Minimal agent creation |
.env |
|
|
Attaching function tools |
.env |
|
|
|
.env |
|
|
Pipeline (SequentialAgent) |
.env |
|
|
FanOut (ParallelAgent) |
.env |
|
|
Loop with max iterations |
.env |
|
|
Coordinator with sub-agents |
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
Operators & routing¶
Examples demonstrating the expression algebra and routing.
Example |
Description |
Prerequisites |
Run command |
|---|---|---|---|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
All operators combined |
.env |
|
Patterns & state¶
State management, presets, decorators, and serialization.
Example |
Description |
Prerequisites |
Run command |
|---|---|---|---|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
LLM-driven agent_tool |
.env |
|
|
Full expression language |
.env |
|
|
|
.env |
|
|
|
.env |
|
Primitives¶
Advanced primitives for observation, testing, and control flow.
Example |
Description |
Prerequisites |
Run command |
|---|---|---|---|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
|
|
.env |
|
Real-world ports¶
Multi-agent systems ported from Google ADK Samples.
Example |
Description |
Prerequisites |
Run command |
|---|---|---|---|
|
Router with nested sub-agents |
.env |
|
|
Multi-stage research pipeline |
.env |
|
|
Multi-agent financial advisory |
.env |
|
|
Sequential pipeline with callbacks |
.env |
|
|
Multi-agent research pipeline |
.env |
|
|
Campfire story creator |
.env |
|
|
Multi-agent travel advisory |
.env |
|
|
Weather lookup agent |
.env |
|
Cookbook examples¶
The examples/cookbook/ directory contains 58 annotated examples that
appear in the Cookbook documentation.
These are equivalence tests — they verify that fluent builders
produce identical ADK objects to native constructors. They do not
call any LLM APIs, so no API key or .env file is needed.
# Run all cookbook tests
pytest examples/cookbook/ -v
# Run a single example
pytest examples/cookbook/01_simple_agent.py -v