Principle:A5c ai Babysitter Lifecycle Event Emission
| Knowledge Sources | |
|---|---|
| Domains | Kubernetes, Lifecycle_Events, Observability |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
A method for broadcasting structured lifecycle events at key agent dispatch flow transitions for observability and hooks.
Description
Lifecycle Event Emission is the principle of emitting structured events at well-defined transitions in the dispatch lifecycle. Nine event types cover the full dispatch flow: run creation/completion, step start/end, approval request/decision, workspace provisioning, and session start/end.
Each event includes a timestamp, run ID, and relevant metadata. Events are broadcast to an event bus, enabling downstream consumers (hooks, dashboards, audit logs) to react without coupling to the dispatch logic.
Usage
Use this principle when designing agent dispatch systems where observability, hooks, and audit trails require structured lifecycle events.
Theoretical Basis
The emission is a fan-out to an event bus:
emitter = createHooksLifecycleEmitter(eventBus)
emitter.emitRunCreated(run) -> eventBus.emit({ type: 'hook', event: 'RUN_CREATED', ... })
emitter.emitStepStarted(run, step) -> eventBus.emit({ type: 'hook', event: 'STEP_STARTED', ... })
emitter.emitRunCompleted(run, result) -> eventBus.emit({ type: 'hook', event: 'RUN_COMPLETED', duration, ... })
Key property: The emitter is decoupled from the dispatch logic — it only reads from run/step/approval objects and broadcasts. This enables adding new consumers without modifying dispatch code.