Types

Link copied to clipboard
class Aborted(val steps: List<StepResult>) : AgentEvent

Fired when generation is aborted via AbortSignal before it finishes. Carries the steps completed up to the abort.

Link copied to clipboard
class Chunk(val event: StreamEvent, val stepNumber: Int) : AgentEvent

Each individual stream chunk, alongside the step it belongs to.

Link copied to clipboard
class Errored(val error: Throwable, val stepNumber: Int, val source: AgentEvent.Errored.ErrorSource) : AgentEvent
Link copied to clipboard
class Finished<TContext, TOutput>(val output: TOutput?, val totalSteps: Int, val usage: Usage, val pendingApprovals: List<PendingApproval> = emptyList(), val messages: List<ModelMessage> = emptyList(), val experimentalContext: TContext? = null) : AgentEvent

Generation finished. output is the typed agent output (was Any?); experimentalContext is the typed context after any prepareStep override (was Any?). messages is the final accumulated message list, for resuming after a tool-approval pause without re-walking the events.

Link copied to clipboard
class ModelCallFinished(val stepNumber: Int, val modelId: String?, val finishReason: FinishReason, val usage: Usage, val response: LanguageModelResponseMetadata = LanguageModelResponseMetadata(), val rawFinishReason: String? = null) : AgentEvent

After one step's model call streamed to completion.

Link copied to clipboard
class ModelCallStarted(val stepNumber: Int, val modelId: String?, val params: LanguageModelCallParams) : AgentEvent

Before one step's model call — the EXACT prepared params sent to the provider.

Link copied to clipboard
class SpanEmitted(val name: String, val attributes: Map<String, JsonElement> = emptyMap()) : AgentEvent

A span sub-event (name + attributes), emitted via TelemetryActiveSpan.addEvent.

Link copied to clipboard
class Started<TContext>(val prompt: String?, val priorMessages: List<ModelMessage>, val options: TContext?) : AgentEvent

Generation started. options is the typed agent context (was Any?).

Link copied to clipboard
class StepFinished(val stepNumber: Int, val step: StepResult) : AgentEvent
Link copied to clipboard
class StepStarted(val stepNumber: Int, val messages: List<ModelMessage>, val request: LanguageModelCallParams, val priorSteps: List<StepResult>) : AgentEvent

Fired before each loop step's model call, AFTER prepareCall + prepareStep have resolved it. request carries the EXACT prepared params (system prompt, tool subset, sampler overrides); priorSteps are the accumulated step results (priorSteps[i] is step i+1's outcome, empty on step 1). Both required — the event fires only once the params exist.

Link copied to clipboard
class ToolCallFinished(val toolCallId: String, val toolName: String, val outcome: AgentEvent.ToolCallFinished.Outcome, val stepNumber: Int) : AgentEvent

Fired immediately after a tool's executor returns or throws. Carries an owned typed outcome instead of paired nullable success/error fields.

Link copied to clipboard
class ToolCallStarted(val toolCallId: String, val toolName: String, val input: JsonElement, val stepNumber: Int, val messages: List<ModelMessage>) : AgentEvent

Fired immediately before a tool's executor runs. Carries the parsed tool call envelope and the messages-list snapshot so observers can record context.