#[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
AssistantText
Model generated text without tool calls.
ToolCall
Model requested to execute a tool.
Latency
Time taken for the LLM request (excluding tool execution), in ms.
ToolResult
Result of executing a tool call.
Usage
Token usage statistics from the LLM provider.
PartialToken
Partial token from streaming response (if streaming enabled).
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.
Compacted
Transcript was compacted to fit size constraints.
TurnFinished
Agent run completed.
Fields
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.
PlanModeApproved
Goal-202: The user approved the plan-mode entry request.
PlanModeRejected
Goal-202: The user rejected the plan-mode entry request.
PlanProposed
Agent has produced a plan and is waiting for confirmation.
PlanConfirmed
Plan was confirmed, execution will proceed.
PlanRejected
Plan was rejected with a reason.
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
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.
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.
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.
GoalSet
A /goal was set for this session.
Fields
GoalContinuing
The judge evaluated the condition and found it not yet met. The loop will continue with another turn.
Fields
GoalAchieved
The judge evaluated the condition and confirmed it is met.
Fields
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.
HookProgress
A hook produced incremental stdout output.
HookFinished
A hook finished executing.
HookSystemMessage
A hook produced a system message to show to the user.
Trait Implementations§
Source§impl Clone for AgentEvent
impl Clone for AgentEvent
Source§fn clone(&self) -> AgentEvent
fn clone(&self) -> AgentEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AgentEvent
impl Debug for AgentEvent
Source§impl<'de> Deserialize<'de> for AgentEvent
impl<'de> Deserialize<'de> for AgentEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for AgentEvent
impl PartialEq for AgentEvent
Source§fn eq(&self, other: &AgentEvent) -> bool
fn eq(&self, other: &AgentEvent) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for AgentEvent
impl Serialize for AgentEvent
impl StructuralPartialEq for AgentEvent
Auto Trait Implementations§
impl Freeze for AgentEvent
impl RefUnwindSafe for AgentEvent
impl Send for AgentEvent
impl Sync for AgentEvent
impl Unpin for AgentEvent
impl UnsafeUnpin for AgentEvent
impl UnwindSafe for AgentEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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