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
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: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
- β 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:- Agent crash kills main process
- No automatic recovery
- Sessions lost on crash
β Supervisor Pattern (Production-Ready)
Running Google ADK in an isolated process:- Process isolation β
- Auto-restart on crash β
- Session state preserved β
- MCP connections managed β
π 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
Creategoogle_adk_agent/adk_agent.py:
Step 2: Callback Function
Creategoogle_adk_agent/callback.py:
Step 3: Runner with Supervisor
Createagent_runner.py:
Step 4: Run It
Using Different LLM Providers
Google ADK works with any LLM via LiteLLM:Session Management
Google ADK uses sessions to maintain conversation history. With supervisors, sessions persist across restarts:Production Deployment
Environment Variables
Horizontal Scaling
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
Related Documentation
Understanding Supervisors:- Agent Supervisor Architecture - How supervisors work internally
- Process Isolation - Dependency and resource isolation
- Complete Agent Process Flow - Full lifecycle walkthrough
- Common Patterns - Production best practices
- OmniCore Agent Example - Alternative framework with supervisors
- Content Moderation Pipeline - Multi-agent system
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.