Agent Lifecycle Management
This page explains the complete lifecycle of an agent in OmniDaemon, from registration to deletion, including pausing and resuming operations.Overview
An agent in OmniDaemon goes through several states during its lifetime:1. Registration
Registration is when you tell OmniDaemon about your agent and what topic it should listen to.Simple Registration
What Happens During Registration
-
Agent metadata stored in the storage backend:
-
Consumer group created on the event bus:
- Agent starts listening for events on the topic
- Start time recorded in storage (for health checks and uptime tracking)
Registration Options
Multiple Agents
You can register multiple agents in the same runner:2. Active State (Processing)
Once registered and started, your agent is active and processing events.Event Processing Flow
Example Processing
Monitoring Active Agents
3. Pausing (Unsubscribe)
Sometimes you want to pause an agent without deleting it completely. This is useful for:- Temporary maintenance
- Testing changes before deploying
- Scaling down during low traffic
- Debugging issues
How to Pause
Via SDK:What Happens When Paused
-
Agent stops consuming new messages
- No new events delivered to this agent
- Other agents in the group (if any) continue
-
Consumer group remains on event bus
- Message history preserved
- Position in stream maintained
-
Agent metadata kept in storage
- Still shows as registered
- Can see configuration and history
-
DLQ preserved (if it exists)
- Failed messages not deleted
- Can still inspect and retry
Resuming from Pause
To resume a paused agent, simply restart your agent runner:- Re-register with same configuration
- Resume from where it left off
- Start processing new events
- Consumer group still exists
- Event bus remembers last processed position
- Agent picks up from there
4. Deletion
Deletion permanently removes an agent and optionally cleans up its infrastructure.Simple Delete (Keep Infrastructure)
Deletes agent from registry but keeps consumer group and DLQ: Via SDK:Complete Delete (Clean Everything)
Deletes agent AND cleans up all infrastructure: Via SDK:What Happens During Deletion
Simple Delete:- ✅ Agent removed from registry
- ✅ Stops processing new events
- ❌ Consumer group NOT deleted
- ❌ DLQ NOT deleted
- ❌ Message history preserved
- ✅ Agent removed from registry
- ✅ Stops processing new events
- ✅ Consumer group deleted
- ✅ DLQ deleted (if requested)
- ✅ All infrastructure cleaned up
Delete Entire Topic
Remove all agents for a topic: Via SDK:5. Graceful Shutdown
When you stop your agent runner (Ctrl+C), OmniDaemon performs a graceful shutdown:What Happens During Shutdown
-
Stop accepting new messages
- Agent unsubscribes from topic
- No new events delivered
-
Finish current processing
- In-flight messages completed
- Results stored
-
Clean up resources
- Close event bus connections
- Close storage connections
- Release memory
-
Clear start time from storage
- Health checks show “stopped”
- Uptime resets
-
Exit cleanly
- No hanging processes
- No orphaned connections
Handling Signals
OmniDaemon handles these signals gracefully:Lifecycle Management Strategies
Development
Staging
Production
Health Monitoring
Check Agent Status
Real-Time Status
Thehealth command shows real-time status:
running- Agent runner active, processing eventsstopped- Agent runner not running (but agents still registered)ready- No agents registered, infrastructure healthydegraded- Some infrastructure unhealthydown- Critical infrastructure down
Advanced Patterns
Conditional Registration
Register agents based on environment:Dynamic Agent Registration
Register agents based on configuration:Health-Check-Based Registration
Only register if dependencies are healthy:Best Practices
1. Use Descriptive Names
2. Version Your Agents
3. Handle Shutdown Gracefully
4. Monitor Agent Health
5. Use Unsubscribe for Maintenance
Troubleshooting
Agent Not Processing Events
Agent Stuck After Shutdown
Can’t Delete Agent
Further Reading
- Event-Driven Architecture - How EDA works in OmniDaemon
- Event Bus Architecture - Deep dive into event bus
- Enterprise Deployment - Horizontal scaling
- Getting Started - Build your first agent
Summary
Agent Lifecycle States:- Unregistered - Agent doesn’t exist yet
- Registered & Active - Agent processing events
- Paused (Unsubscribed) - Agent stopped, infrastructure preserved
- Deleted - Agent removed, optionally clean up infrastructure
register_agent()- Create and start agentunsubscribe_agent()- Pause agent (keep infrastructure)delete_agent()- Remove agent (optionally clean up)shutdown()- Graceful stop
omnidaemon health- Real-time system statusomnidaemon agent list- All registered agentsomnidaemon metrics- Processing statistics