Skip to main content

AgentEvent

Enum AgentEvent 

Source
#[non_exhaustive]
pub enum AgentEvent {
Show 27 variants AssistantText { text: String, step: usize, }, ToolCall { name: String, id: String, arguments: String, step: usize, }, Latency { step: usize, llm_ms: u64, }, ToolResult { id: String, name: String, output: String, step: usize, }, Usage { input_tokens: u32, output_tokens: u32, step: usize, }, PartialToken { text: String, step: usize, }, Reasoning { text: String, step: usize, }, Compacted { removed: usize, kept: usize, summary_chars: usize, step: usize, }, TurnFinished { reason: String, steps: usize, }, PlanModeRequested { reason: String, }, PlanModeApproved, PlanModeRejected { reason: String, }, PlanProposed { plan_text: String, tool_calls: Vec<Value>, }, PlanConfirmed, PlanRejected { reason: String, }, MessageAppended { message: Message, parent_uuid: Option<String>, usage: Option<UsageMeta>, }, MessageAppendedWithAudit { message: Message, audit: AuditMeta, }, CompactionBoundary { turn: u32, compacted_count: usize, summary_uuid: Option<String>, }, TodoUpdated { todos: Vec<TodoItem>, }, GoalSet { condition: String, max_turns: u32, }, GoalContinuing { reason: String, turns: u32, }, GoalAchieved { condition: String, turns: u32, }, GoalCleared, HookStarted { hook_event: String, hook_name: String, status_message: Option<String>, }, HookProgress { hook_event: String, hook_name: String, last_line: String, }, HookFinished { hook_event: String, hook_name: String, outcome: String, duration_ms: u64, }, HookSystemMessage { text: String, },
}
Expand description

A serialisable, non-exhaustive agent lifecycle event.

Uses String for the finish reason to avoid coupling to the FinishReason type. New variants can be added without a breaking change (see #[non_exhaustive]).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

AssistantText

Model generated text without tool calls.

Fields

§text: String
§step: usize
§

ToolCall

Model requested to execute a tool.

Fields

§name: String
§arguments: String
§step: usize
§

Latency

Time taken for the LLM request (excluding tool execution), in ms.

Fields

§step: usize
§llm_ms: u64
§

ToolResult

Result of executing a tool call.

Fields

§name: String
§output: String
§step: usize
§

Usage

Token usage statistics from the LLM provider.

Fields

§input_tokens: u32
§output_tokens: u32
§step: usize
§

PartialToken

Partial token from streaming response (if streaming enabled).

Fields

§text: String
§step: usize
§

Reasoning

Reasoning / thinking content from a model that exposes an explicit reasoning channel (DeepSeek R1, OpenAI o1, etc.). Carries the full reasoning text for the current step; providers that stream reasoning tokens (DeepSeek’s reasoning_content SSE deltas) accumulate them and emit the final, fully-joined string in this event. UI layers render it as a thinking… block separate from the assistant message body. Emitted exactly once per step that produced reasoning content; steps without reasoning skip the event.

Fields

§text: String
§step: usize
§

Compacted

Transcript was compacted to fit size constraints.

Fields

§removed: usize
§kept: usize
§summary_chars: usize
§step: usize
§

TurnFinished

Agent run completed.

Fields

§reason: String

Human-readable reason for termination (e.g. “no_more_tool_calls”).

§steps: usize

Number of iterations executed.

§

PlanModeRequested

Goal-202: Agent is requesting permission to enter plan mode. Emitted by RequestPlanModeTool before any exploration begins. The TUI / HTTP surface should prompt the user and call AgentRuntime::approve_plan_mode_request or reject_plan_mode_request.

Fields

§reason: String
§

PlanModeApproved

Goal-202: The user approved the plan-mode entry request.

§

PlanModeRejected

Goal-202: The user rejected the plan-mode entry request.

Fields

§reason: String
§

PlanProposed

Agent has produced a plan and is waiting for confirmation.

Fields

§plan_text: String
§tool_calls: Vec<Value>
§

PlanConfirmed

Plan was confirmed, execution will proceed.

§

PlanRejected

Plan was rejected with a reason.

Fields

§reason: String
§

MessageAppended

A complete message was just appended to the agent transcript.

Fired exactly once per committed message inside the agent runtime: once for the user message that starts a turn, once for the compaction summary if cross-turn compaction fires, and once per message in the kernel’s output batch. Carries the full Message (role, content, tool_calls, tool_call_id, reasoning_content) so persistence consumers can write the canonical record without reassembling it from the finer AssistantText / ToolCall / ToolResult streaming events.

parent_uuid — if Some, the emitter wants this message to be written as a branch off the given UUID rather than the SessionWriter’s internal chain pointer. Used by subagent runtimes (g155).

usage — token usage for this message (non-None for assistant messages produced by an LLM call, g156).

Not emitted for seeded transcript messages loaded from an existing session on resume (those are already on disk).

Fields

§message: Message
§parent_uuid: Option<String>

Explicit parent UUID override for subagent branch points (g155).

§usage: Option<UsageMeta>

Token usage for this message (g156).

§

MessageAppendedWithAudit

Variant of [MessageAppended] specifically for Role::Tool messages that have an associated [AuditMeta] (Goal 153). The persistence sink handles this identically to MessageAppended but populates the audit field of crate::session::TranscriptEntry.

Emitting a separate variant (rather than Option<AuditMeta> on MessageAppended) keeps the common path zero-cost and avoids making audit an optional field on every event.

Fields

§message: Message
§

CompactionBoundary

Cross-turn compaction just fired; a compact_boundary marker should be written to the session JSONL (g157).

turn — the turn index when compaction occurred. compacted_count — how many messages were removed. summary_uuid — UUID of the compaction summary message that replaced them.

Fields

§turn: u32
§compacted_count: usize
§summary_uuid: Option<String>
§

TodoUpdated

Goal-167: emitted when the agent updates its task checklist via todo_write. Carries the complete replacement list so consumers can render the current state without storing diffs.

Fields

§todos: Vec<TodoItem>
§

GoalSet

A /goal was set for this session.

Fields

§condition: String

The completion condition as written by the user.

§max_turns: u32

Hard cap on autonomous turns.

§

GoalContinuing

The judge evaluated the condition and found it not yet met. The loop will continue with another turn.

Fields

§reason: String

The judge’s explanation for why the condition is not yet met.

§turns: u32

Number of turns elapsed so far.

§

GoalAchieved

The judge evaluated the condition and confirmed it is met.

Fields

§condition: String

The original condition string.

§turns: u32

Total turns taken to reach the goal.

§

GoalCleared

The active goal was cleared — either by /goal clear, turn-budget exhaustion, or an explicit DELETE /sessions/:id/goal call.

§

HookStarted

A hook started executing.

Fields

§hook_event: String
§hook_name: String
§status_message: Option<String>
§

HookProgress

A hook produced incremental stdout output.

Fields

§hook_event: String
§hook_name: String
§last_line: String
§

HookFinished

A hook finished executing.

Fields

§hook_event: String
§hook_name: String
§outcome: String
§duration_ms: u64
§

HookSystemMessage

A hook produced a system message to show to the user.

Fields

§text: String

Trait Implementations§

Source§

impl Clone for AgentEvent

Source§

fn clone(&self) -> AgentEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AgentEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for AgentEvent

Source§

fn eq(&self, other: &AgentEvent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for AgentEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AgentEvent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more