Overview
The Agent Orchestrator uses an event-driven architecture for communication between the lifecycle manager, notification system, and reaction engine. Events represent state transitions and important occurrences in session lifecycles.There is no dedicated EventBus class - events are created and dispatched directly by the Lifecycle Manager. This page documents the event system as implemented across the codebase.
- Events are emitted on session state transitions
- Each event has a priority level (urgent, action, warning, info)
- Events are routed to notifiers based on priority
- Events can trigger automated reactions
Event Structure
Event Types
All event types are string literals defined in theEventType union:
Session Lifecycle Events
Events related to session creation, execution, and termination.session.spawned
session.spawned
Trigger: Session enters Example:
spawning statusPriority: infoData:session.working
session.working
Trigger: Session enters
working statusPriority: infoData:session.exited
session.exited
Trigger: Agent process exits (activity state becomes Reaction:
exited)Priority: urgentData:agent-exited - Notifies human immediatelysession.stuck
session.stuck
Trigger: Session enters Reaction:
stuck status (agent idle for too long)Priority: urgentData:agent-stuck - Notifies human after threshold (default: 10 minutes)session.needs_input
session.needs_input
Trigger: Session enters Reaction:
needs_input status (agent asking a question)Priority: urgentData:agent-needs-input - Notifies human immediatelysession.errored
session.errored
Trigger: Session enters
errored statusPriority: urgentData:PR Lifecycle Events
Events related to pull request creation and status changes.pr.created
pr.created
Trigger: Session enters Example:
pr_open statusPriority: infoData:pr.merged
pr.merged
Trigger: Session enters
merged statusPriority: actionData:pr.closed
pr.closed
Trigger: PR is closed without mergingPriority: warningData:
CI Events
Events related to continuous integration checks.ci.failing
ci.failing
Trigger: Session enters Reaction:
ci_failed statusPriority: warningData:ci-failed - Sends message to agent with instructions to fixExample:ci.passing
ci.passing
Trigger: All CI checks pass after previously failingPriority: infoData:
Review Events
Events related to code review activity.review.pending
review.pending
Trigger: Session enters
review_pending statusPriority: infoData:review.approved
review.approved
Trigger: Session enters
approved statusPriority: actionData:review.changes_requested
review.changes_requested
Trigger: Session enters Reaction:
changes_requested statusPriority: warningData:changes-requested - Sends comments to agent with instructions to addressMerge Events
Events related to merge readiness and completion.merge.ready
merge.ready
Trigger: Session enters Reaction:
mergeable status (approved + CI passing + no conflicts)Priority: actionData:approved-and-green - Notifies human that PR is ready to mergemerge.completed
merge.completed
Trigger: PR is successfully mergedPriority: actionData:
Reaction Events
Events emitted by the reaction system itself.reaction.triggered
reaction.triggered
Trigger: A reaction is executedPriority: info (or reaction’s configured priority)Data:
reaction.escalated
reaction.escalated
Trigger: A reaction escalates to human notification after retries/timeoutPriority: urgentData:
Summary Events
summary.all_complete
summary.all_complete
Trigger: All sessions are in terminal states (merged/killed)Priority: infoData:Reaction:
all-complete - Sends summary notificationEvent Priorities
Events have one of four priority levels:Priority Levels
Critical issues requiring immediate human attention.Examples:
- Agent stuck or crashed
- Agent asking a question (needs_input)
- Session errored
- Reaction escalated after max retries
Actionable events that may require human decision.Examples:
- PR approved and ready to merge
- PR merged successfully
- Review completed
Issues that may need attention but aren’t blocking.Examples:
- CI checks failing (but reaction is auto-fixing)
- Review changes requested (but reaction is handling)
- Merge conflicts detected
Informational updates about progress.Examples:
- Session spawned
- PR created
- CI passing
- All sessions complete
Priority Inference
The lifecycle manager automatically infers priority from event type:Event Creation
Events are created by the lifecycle manager using a factory function:Event Routing
Events are routed to notifiers based on priority:Routing Logic
Custom Routing
You can customize routing per priority level:Event-Triggered Reactions
Events can trigger automated reactions. The lifecycle manager maps event types to reaction config keys:Complete Example
See Also
- Lifecycle Manager - Event emission and reaction system
- Plugin: Notifier - Notification delivery
- Config Loader - Notification routing configuration
