events

fun events(prompt: String? = null, messages: List<ModelMessage> = emptyList(), options: TContext? = null, abortSignal: AbortSignal = AbortSignalNever): Flow<AgentEvent>(source)

Observe the FULL agent-lifecycle event stream as a Flow<AgentEvent> — the Flow-first replacement for the former bag of nullable onX callbacks. Cold: one loop run per collection. Carries every lifecycle event (AgentEvent.Started, AgentEvent.StepStarted, every AgentEvent.Chunk, AgentEvent.StepFinished, the tool-call pair, AgentEvent.Errored, AgentEvent.Aborted, AgentEvent.Finished).

Collect with an exhaustive when (no else), or use collectAgentEvents. stream stays the curated Flow<StreamEvent> (model deltas only); this is the superset that also surfaces the loop's own lifecycle boundaries.

Since

0.3.0-beta01