Skip to main content

Google ADK Agent Example

Learn how to run Google Agent Development Kit (ADK) agents in production with OmniDaemon using the Supervisor pattern.
πŸ’‘ Working code: examples/google_adk_with_supervisor/

The Challenge

When you build AI agents with Google ADK (or any framework), running them in production means dealing with:
  • ❌ Agent crashes - Memory errors, API failures, unexpected exceptions
  • ❌ Resource leaks - Connections that don’t close, memory that doesn’t free
  • ❌ No fault isolation - One agent’s problem affects your entire system
  • ❌ Manual recovery - You have to restart everything manually
Google ADK gives you great tools for building agents, but it doesn’t solve these operational challenges. That’s where OmniDaemon’s supervisors come in.

The Supervisor Solution

Supervisors run your Google ADK agent in an isolated process - like putting it in its own container.

What This Means for Your Google ADK Agent

Without Supervisor:
With Supervisor:

Why This Matters for Google ADK

Google ADK agents often:
  • Maintain session state for conversations
  • Connect to MCP servers for tools (filesystem, GitHub, etc.)
  • Make external API calls to Gemini or other LLMs
  • Hold persistent connections
All of these can fail. The Supervisor ensures:
  • βœ… Failures are isolated
  • βœ… Sessions can be recovered
  • βœ… MCP connections restart cleanly
  • βœ… No manual intervention needed
πŸ“š How supervisors work: Agent Supervisor Architecture explains the technical implementation details.

How It Works

❌ Simple Pattern (Not Production-Ready)

Running Google ADK directly in your main process:
Problems:
  • Agent crash kills main process
  • No automatic recovery
  • Sessions lost on crash

βœ… Supervisor Pattern (Production-Ready)

Running Google ADK in an isolated process:
Benefits:
  • Process isolation βœ…
  • Auto-restart on crash βœ…
  • Session state preserved βœ…
  • MCP connections managed βœ…
The supervisor spawns a new Python process, loads your Google ADK agent, and manages its entire lifecycle.
πŸ“š Complete flow: Agent Process Flow shows exactly how events flow from OmniDaemon β†’ Supervisor β†’ Google ADK β†’ Response.

Implementation

Now that you understand why supervisors matter for Google ADK, let’s build it.

Prerequisites

Directory Structure

Step 1: Google ADK Setup

Create google_adk_agent/adk_agent.py:

Step 2: Callback Function

Create google_adk_agent/callback.py:
Key Point: This entire callback runs in an isolated process. If it crashes, only this process dies - the supervisor restarts it automatically.

Step 3: Runner with Supervisor

Create agent_runner.py:

Step 4: Run It

Your Google ADK agent is now running in an isolated process, managed by the supervisor!

Using Different LLM Providers

Google ADK works with any LLM via LiteLLM:
Just change the model config - the supervisor pattern stays the same.

Session Management

Google ADK uses sessions to maintain conversation history. With supervisors, sessions persist across restarts:
If the agent process crashes and restarts, sessions are recreated automatically by the supervisor.

Production Deployment

Environment Variables

Horizontal Scaling

Each instance runs its own isolated Google ADK process. OmniDaemon distributes events across all instances.

Monitoring


Complete Working Example

See the full production implementation: πŸ“ examples/google_adk_with_supervisor/ This example shows:
  • Complete Google ADK setup
  • MCP filesystem tools
  • Session management
  • Process isolation with supervisors
  • Error handling
  • Graceful shutdown

Understanding the Architecture

Process Flow

Understanding Supervisors: Implementation Details: Other Examples:

Key Takeaways

βœ… Supervisors make Google ADK production-ready - Process isolation prevents cascading failures
βœ… Session state is preserved - Sessions survive process restarts
βœ… Works with any LLM - Gemini, OpenAI, Anthropic via LiteLLM
βœ… Simple integration - create_supervisor_from_directory() handles complexity
βœ… Auto-recovery - Crashed agents restart automatically with sessions intact
Google ADK is excellent for building agents. Supervisors make them production-ready. Together with OmniDaemon, you get fault-tolerant, scalable AI systems.
Next: Check out the content moderation example for a multi-agent pipeline using supervisors.