Skip to main content

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.
Key concepts:
  • 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

Example:

Event Types

All event types are string literals defined in the EventType union:

Session Lifecycle Events

Events related to session creation, execution, and termination.
Trigger: Session enters spawning statusPriority: infoData:
Example:
Trigger: Session enters working statusPriority: infoData:
Trigger: Agent process exits (activity state becomes exited)Priority: urgentData:
Reaction: agent-exited - Notifies human immediately
Trigger: Session enters stuck status (agent idle for too long)Priority: urgentData:
Reaction: agent-stuck - Notifies human after threshold (default: 10 minutes)
Trigger: Session enters needs_input status (agent asking a question)Priority: urgentData:
Reaction: agent-needs-input - Notifies human immediately
Trigger: Session enters errored statusPriority: urgentData:

PR Lifecycle Events

Events related to pull request creation and status changes.
Trigger: Session enters pr_open statusPriority: infoData:
Example:
Trigger: Session enters merged statusPriority: actionData:
Trigger: PR is closed without mergingPriority: warningData:

CI Events

Events related to continuous integration checks.
Trigger: Session enters ci_failed statusPriority: warningData:
Reaction: ci-failed - Sends message to agent with instructions to fixExample:
Trigger: All CI checks pass after previously failingPriority: infoData:

Review Events

Events related to code review activity.
Trigger: Session enters review_pending statusPriority: infoData:
Trigger: Session enters approved statusPriority: actionData:
Trigger: Session enters changes_requested statusPriority: warningData:
Reaction: changes-requested - Sends comments to agent with instructions to address

Merge Events

Events related to merge readiness and completion.
Trigger: Session enters mergeable status (approved + CI passing + no conflicts)Priority: actionData:
Reaction: approved-and-green - Notifies human that PR is ready to merge
Trigger: PR is successfully mergedPriority: actionData:

Reaction Events

Events emitted by the reaction system itself.
Trigger: A reaction is executedPriority: info (or reaction’s configured priority)Data:
Trigger: A reaction escalates to human notification after retries/timeoutPriority: urgentData:

Summary Events

Trigger: All sessions are in terminal states (merged/killed)Priority: infoData:
Reaction: all-complete - Sends summary notification

Event Priorities

Events have one of four priority levels:

Priority Levels

EventPriority
Critical issues requiring immediate human attention.Examples:
  • Agent stuck or crashed
  • Agent asking a question (needs_input)
  • Session errored
  • Reaction escalated after max retries
Default routing: Desktop + Composio notifications
EventPriority
Actionable events that may require human decision.Examples:
  • PR approved and ready to merge
  • PR merged successfully
  • Review completed
Default routing: Desktop + Composio notifications
EventPriority
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
Default routing: Composio notifications only
EventPriority
Informational updates about progress.Examples:
  • Session spawned
  • PR created
  • CI passing
  • All sessions complete
Default routing: Composio notifications only

Priority Inference

The lifecycle manager automatically infers priority from event type:

Event Creation

Events are created by the lifecycle manager using a factory function:
Example:

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:
See Lifecycle Manager - Reaction System for details on how reactions work.

Complete Example

See Also