OmniCore Agent Example
Learn how to run OmniCore Agent in production with OmniDaemon using the Supervisor pattern.
π‘ Working code: examples/agents_with_supervisors/
The Challenge
When running AI agents in production, you face a critical problem: one agent crash shouldnβt kill your entire system. Most AI frameworks run everything in a single Python process:- β Agent crashes β entire process dies
- β Memory leak in one agent β affects all agents
- β No isolation β agents share the same memory space
- β Exception in agent code β takes down the whole system
The Supervisor Solution
OmniDaemon solves this with Agent Supervisors - lightweight process managers for your AI agents.What is a Supervisor?
A Supervisor is a component that runs your agent in its own isolated process and manages its lifecycle. Think of it like Docker containers, but for Python AI agents:- Each agent runs in a separate process (different PID)
- Supervisor monitors the agent process health
- Automatically restarts crashed agents
- Handles clean shutdown and resource cleanup
- Communicates with agent via stdio (JSON protocol)
Why This Matters
Without Supervisor (all in one process):- β Fault Isolation - Agent A crashes, Agent B keeps running
- β Auto-Recovery - Crashed agents restart automatically
- β Resource Isolation - Each agent has its own memory/CPU space
- β Clean Shutdown - Supervisors handle graceful termination
π Deep Dive: Agent Supervisor Architecture explains the technical details of how supervisors work under the hood.
How It Works
Instead of running your agent callback directly in the main process (risky), you wrap it in a supervisor.β Simple Pattern (Development Only)
- No process isolation
- Crashes affect everything
- No auto-restart
β Supervisor Pattern (Production-Ready)
- Process isolation β
- Auto-restart on crash β
- Resource cleanup β
π How it works internally: Complete Agent Process Flow shows the full lifecycle from event to response.
Implementation
Now that you understand WHY supervisors exist, letβs build a production-ready OmniCore Agent.Prerequisites
Directory Structure
The Supervisor pattern requires your agent code in a directory:π‘ Why a directory? The supervisor needs to spawn a new process with your agent code. Organizing it in a directory allows the supervisor to install dependencies in isolation and import your callback function properly.
Step 1: Agent Code
Createmy_agent/agent.py with your OmniCore Agent logic:
- This code runs in a separate process, not the main process
- MCP tools connect once and stay connected
- Clean separation of concerns
Step 2: Agent Runner
Createagent_runner.py that manages the supervisor:
create_supervisor_from_directory()spawns a new Python process- Process imports
my_agent.agentmodule - Supervisor keeps process running, waiting for events
- When event arrives, supervisor sends it to agent via stdio
- Agent processes and returns result
- Supervisor sends result back to OmniDaemon
Step 3: Run It
Testing Your Agent
Publish an event to test:Production Deployment
Environment Variables
Horizontal Scaling
Run multiple instances for load balancing:Monitoring
Complete Working Example
See the full production implementation with Google ADK: πexamples/agents_with_supervisors/
This example includes:
- Google ADK integration
- MCP filesystem tools
- Process isolation with supervisors
- Error handling
- Graceful shutdown
- Multiple agents
Understanding the Architecture
This supervisor pattern is fundamental to how OmniDaemon achieves production-grade reliability.Process Architecture
Related Documentation
Core Concepts:- Agent Supervisor Architecture - Technical deep dive into how supervisors work
- Process Isolation - How dependencies and resources are isolated
- Complete Agent Process Flow - Step-by-step lifecycle from event to response
- Common Patterns - Production-ready patterns and best practices
- Google ADK with Supervisor - Alternative AI framework with supervisors
- Content Moderation Pipeline - Multi-agent system example
Key Takeaways
β Supervisors provide process isolation - One agent crash doesnβt affect othersβ Production requirement - Use supervisors for any production AI agent
β Simple to use -
create_supervisor_from_directory() handles everythingβ Auto-recovery - Crashed agents restart automatically
β Resource cleanup - Graceful shutdown of MCP tools and connections The supervisor pattern is what makes OmniDaemon production-ready. It transforms your AI agents from fragile single-process scripts into robust, fault-tolerant services.
Next: Try the Google ADK example to see supervisors with a different AI framework.