Skip to main content

AgentEvent

Enum AgentEvent 

Source
pub enum AgentEvent {
Show 38 variants TextDelta { text: String, turn_id: String, }, ThinkingDelta { text: String, turn_id: String, }, ToolUseStart { id: String, name: String, turn_id: String, }, ToolArgsDelta { id: String, partial_json: String, turn_id: String, }, ToolUse { id: String, name: String, input: Value, turn_id: String, }, ToolProgress { tool_use_id: String, name: String, message: String, progress: Option<f64>, total: Option<f64>, dropped: u64, turn_id: String, }, ToolResult { id: String, name: String, content: String, is_error: Option<bool>, turn_id: String, file_changes: Vec<FileChange>, }, PermissionPrompt { prompt_id: String, tool_name: String, message: String, paths: Vec<PathBuf>, turn_id: String, tool_use_id: Option<String>, task_id: Option<String>, agent_session_id: Option<String>, origin: Option<PromptOrigin>, permit_always: bool, }, QuestionPrompt { prompt_id: String, question: String, header: Option<String>, options: Vec<ElicitOption>, turn_id: String, tool_use_id: Option<String>, task_id: Option<String>, agent_session_id: Option<String>, }, McpElicitationPrompt { prompt_id: String, server: String, mode: String, message: String, requested_schema: Option<Value>, url: Option<String>, url_host: Option<String>, limited: bool, turn_id: String, tool_use_id: Option<String>, task_id: Option<String>, agent_session_id: Option<String>, }, PromptResolved { prompt_id: String, resolution: PromptResolution, reason: Option<WithdrawalReason>, }, HostToolCall { call_id: String, tool_use_id: String, name: String, input: Value, timeout_ms: u64, task_id: Option<String>, agent_session_id: Option<String>, cwd: PathBuf, depth: u32, host: Option<HostId>, }, HostToolCallResolved { call_id: String, resolution: PromptResolution, reason: Option<HostCallWithdrawal>, }, HostHookCall { call_id: String, hook_event: String, input: Value, timeout_ms: u64, task_id: Option<String>, agent_session_id: Option<String>, cwd: PathBuf, depth: u32, host: Option<HostId>, }, HostHookCallResolved { call_id: String, resolution: PromptResolution, reason: Option<HostCallWithdrawal>, }, TurnStart { turn_id: String, }, StepStart { step: u32, turn_id: String, }, ModelRetry { step: u32, attempt: u32, delay_ms: u64, reason: String, turn_id: String, }, StepEnd { step: u32, stop_reason: String, usage: Usage, tool_calls: u32, turn_id: String, seq: u64, served: Option<Destination>, }, TurnComplete {
Show 13 fields stop_reason: String, api_calls: u32, tool_calls: u32, usage: Usage, usage_breakdown: UsageBreakdown, turn_id: String, message: Option<String>, last_call_usage: Usage, context: Option<ContextUsage>, structured_output: Option<Value>, seq: u64, truncated: bool, persisted: bool,
}, UserMessageDelivered { message_id: String, content: String, turn_id: String, }, UserMessageRefused { message_id: String, content: String, message: Option<String>, turn_id: String, }, UserMessagesReturned { messages: Vec<QueuedUserMessage>, turn_id: String, }, SystemInit { scene: String, tools: Vec<ToolInfo>, mcp_servers: Vec<String>, }, System { message: String, }, CompactStarted { turn_id: String, trigger: CompactCause, tokens_before: usize, strategy: Option<String>, }, CompactEnded { turn_id: String, outcome: CompactOutcome, reason: Option<String>, }, CompactAction { strategy: String, messages_before: usize, messages_after: usize, turn_id: String, dropped_rounds: Option<usize>, dropped_messages: Option<usize>, estimated_tokens_saved: Option<usize>, tokens_before: usize, tokens_after: usize, trim: bool, }, SessionChanged { session_id: String, }, SessionPersisted { session_id: String, }, SkillsChanged { added: Vec<String>, removed: Vec<String>, turn_id: String, }, Notification { message: String, status: Option<String>, turn_id: String, }, ProviderSwitched(ProviderSwitch), AgentSpawned { agent_id: String, parent_turn: u32, turn_id: String, }, AgentCompleted { agent_id: String, outcome: String, turn_id: String, }, SubagentProgress { agent_label: String, agent_session_id: String, agent_type: Option<String>, parent_session_id: String, parent_turn: u32, parent_tool_use_id: Option<String>, task_id: Option<String>, event: Box<AgentEvent>, }, TeamProgress { team: String, team_id: String, stage: String, stage_index: usize, stage_count: usize, status: TeamStageStatus, members: Vec<String>, failed: Vec<String>, }, Error { failure: TurnFailure, turn_id: String, persisted: bool, },
}
Expand description

Events emitted by the Engine during a turn.

The upper layer (a CLI, a TUI, the daemon, a desktop host) consumes these via EventReceiver and renders/dispatches as appropriate.

Variants§

§

TextDelta

Model text delta (high frequency).

Fields

§text: String
§turn_id: String
§

ThinkingDelta

Extended-thinking delta (high frequency). Separate from AgentEvent::TextDelta so hosts can render reasoning distinctly — collapsed, dimmed, or hidden — instead of splicing it into the answer. A host that does not care can ignore this variant; nothing else depends on it being consumed.

Fields

§text: String
§turn_id: String
§

ToolUseStart

The model has started writing a tool call. ToolUse with the same id follows once its arguments are complete.

Fields

§name: String
§turn_id: String
§

ToolArgsDelta

A raw fragment of a started tool call’s arguments (high frequency). The fragments concatenate to the JSON that ToolUse carries parsed.

Fields

§partial_json: String
§turn_id: String
§

ToolUse

Model requested a tool call.

Fields

§name: String
§input: Value
§turn_id: String
§

ToolProgress

What a running tool call reported through its ProgressSender. At most one a second per call; dropped counts the reports merged away since the previous one. Never written to the transcript.

Fields

§tool_use_id: String
§name: String
§message: String
§progress: Option<f64>
§total: Option<f64>
§dropped: u64
§turn_id: String
§

ToolResult

Tool execution completed.

Fields

§name: String
§content: String
§is_error: Option<bool>
§turn_id: String
§file_changes: Vec<FileChange>

The files the call wrote. Not in the transcript: the model reads content.

§

PermissionPrompt

Permission check requires upper-layer decision.

Fields

§prompt_id: String
§tool_name: String
§message: String
§paths: Vec<PathBuf>
§turn_id: String
§tool_use_id: Option<String>

The tool_use block this prompt is about, when known.

§task_id: Option<String>

The background task whose sub-agent asks, when one does. Its question outlives the turn it happened to arrive during.

§agent_session_id: Option<String>

The sub-agent’s session, when a sub-agent asks.

§origin: Option<PromptOrigin>

The plugin command whose sub-call this is; None for the model’s own.

§permit_always: bool

Whether permit_always is among the answers: an “always” that would never be consulted is not offered.

§

QuestionPrompt

The model asked the user something (AskUserQuestion) and waits for the host’s answer.

Fields

§prompt_id: String
§question: String
§header: Option<String>
§options: Vec<ElicitOption>

Offered answers; empty means free-form.

§turn_id: String
§tool_use_id: Option<String>
§task_id: Option<String>
§agent_session_id: Option<String>

The sub-agent’s session, when a sub-agent asks.

§

McpElicitationPrompt

An MCP server asks the user something during a tool call. message, requested_schema and url are the server’s; url_host is the host part of url, for a host that shows where the link goes.

Fields

§prompt_id: String
§server: String
§mode: String

form or url.

§message: String
§requested_schema: Option<Value>
§url_host: Option<String>
§limited: bool

The engine cut message down to the length it puts to a person.

§turn_id: String
§tool_use_id: Option<String>
§task_id: Option<String>
§agent_session_id: Option<String>

The sub-agent’s session, when a sub-agent asks.

§

PromptResolved

The ask prompt_id — a PermissionPrompt, QuestionPrompt or McpElicitationPrompt — is no longer open: answered, or given up on. Emitted once per ask, by the engine that stopped waiting on it.

Fields

§prompt_id: String
§resolution: PromptResolution
§reason: Option<WithdrawalReason>

Why it was withdrawn; None when it was answered.

§

HostToolCall

A tool the host declared was called: the host runs it and answers with call_id. Comes after the call’s ToolUse and before its ToolResult.

Fields

§call_id: String
§tool_use_id: String
§name: String
§input: Value
§timeout_ms: u64
§task_id: Option<String>

As PermissionPrompt::task_id.

§agent_session_id: Option<String>

The sub-agent’s session, when a sub-agent made the call.

§cwd: PathBuf

As HostCall::cwd.

§depth: u32

As HostCall::depth.

§host: Option<HostId>

The connection that provides the tool, when one does.

§

HostToolCallResolved

The host call call_id is no longer open. Emitted once per call.

Fields

§call_id: String
§resolution: PromptResolution
§

HostHookCall

A hook host registered fires: the host answers it with call_id. input is the payload a command hook reads on stdin.

Fields

§call_id: String
§hook_event: String
§input: Value
§timeout_ms: u64
§task_id: Option<String>
§agent_session_id: Option<String>
§depth: u32
§

HostHookCallResolved

The hook call call_id is no longer open. Emitted once per call.

Fields

§call_id: String
§resolution: PromptResolution
§

TurnStart

A turn has started. Every TurnStart is followed by exactly one TurnComplete or Error with the same turn_id.

Fields

§turn_id: String
§

StepStart

The turn is about to call the model. step counts the turn’s model calls from 0.

Fields

§step: u32
§turn_id: String
§

ModelRetry

Model call step failed after its stream had started, and is sent again as it was once delay_ms has passed; a StepStart of the same step follows. attempt counts these retries of the call from 1; reason is the failure.

Fields

§step: u32
§attempt: u32
§delay_ms: u64
§reason: String
§turn_id: String
§

StepEnd

The model call step has finished and its reply — plus the results of the tools it asked for — is in the transcript.

Fields

§step: u32
§stop_reason: String
§usage: Usage

What this one call cost.

§tool_calls: u32
§turn_id: String
§seq: u64

How many messages the transcript holds now — the same position session.history pages by. Everything this step produced is on disk below it.

§served: Option<Destination>

Where a routed call went; None when nothing routed it.

§

TurnComplete

A turn has completed.

Fields

§stop_reason: String
§api_calls: u32
§tool_calls: u32
§usage: Usage

Every call of the turn as it ends: its own, its side calls’ and its delegates’, split in usage_breakdown. A background delegate’s calls after the turn ended are not in it.

§usage_breakdown: UsageBreakdown
§turn_id: String
§message: Option<String>

Why the turn was stopped, when whatever stopped it said so — a hook’s message, for instance.

§last_call_usage: Usage

What the turn’s last model call reported. usage is the sum.

§context: Option<ContextUsage>

How full the context is. None when the turn made no model call.

§structured_output: Option<Value>

What the model last handed to StructuredOutput in this turn — validated against the host’s schema when the session has one.

§seq: u64

The transcript position the turn ended at; see StepEnd::seq.

§truncated: bool

A model call of this turn ended without the provider marking the end of its reply (crate::interface::model::ModelEvent::Truncated), so the reply may be cut short.

§persisted: bool

Everything the turn did is in the session’s log. false when a write failed: the session holds the only complete copy until a later write catches the log up.

§

UserMessageDelivered

A message the user sent while this turn was running is now part of the conversation; the model reads it on its next call.

Fields

§message_id: String
§content: String
§turn_id: String
§

UserMessageRefused

A message the user sent while this turn was running was refused on its way in (UserPromptSubmit blocked it). It is not in the transcript and the turn goes on; sending it again would be refused again.

Fields

§message_id: String
§content: String
§message: Option<String>
§turn_id: String
§

UserMessagesReturned

Messages the user sent while this turn was running that the model never got to read — the turn ended (interrupted, stopped by a policy or an error) before the next point they could be added. They are not in the transcript; whether to send them again is the host’s call.

Fields

§turn_id: String
§

SystemInit

System initialization completed.

Fields

§scene: String
§tools: Vec<ToolInfo>
§mcp_servers: Vec<String>
§

System

System notification.

Fields

§message: String
§

CompactStarted

A compaction that rewrites the history is about to run, before its PreCompact hooks. It ends in exactly one CompactAction (it went through) or one CompactEnded (it did not). Trims send neither.

Fields

§turn_id: String
§tokens_before: usize

The compactor’s estimate of the history’s size now.

§strategy: Option<String>

Set only when the strategy is already fixed.

§

CompactEnded

The compaction a CompactStarted announced left the history as it was.

Fields

§turn_id: String
§reason: Option<String>
§

CompactAction

The history was compacted or trimmed.

Fields

§strategy: String
§messages_before: usize
§messages_after: usize
§turn_id: String
§dropped_rounds: Option<usize>

Number of rounds dropped by the Snip strategy (if applicable).

§dropped_messages: Option<usize>

Number of messages in dropped rounds (if applicable).

§estimated_tokens_saved: Option<usize>

Estimated tokens saved by the compaction (if applicable).

§tokens_before: usize

The compactor’s estimate of the history’s size before and after.

§tokens_after: usize
§trim: bool

The history was trimmed (old tool results blanked), not compacted: no message was dropped and no PreCompact/PostCompact ran.

§

SessionChanged

Session was changed (via set_session_id).

Fields

§session_id: String
§

SessionPersisted

Session was persisted to disk.

Fields

§session_id: String
§

SkillsChanged

The skill catalog changed on disk — emitted at the top of the turn that observed it, right after the reload.

Skill-derived slash commands resolve through the live catalog, so a host that caches a command list (a completion popup, a command palette) has no other way to learn its copy went stale short of polling. Names are skill names, i.e. slash commands without the leading /.

Content edits to an existing skill are not reported: the reload is detected by set difference over the catalog, which sees a rename as one removal plus one addition and an in-place body edit as nothing at all. That is the honest scope — a consumer that cares about bodies should re-read on any change rather than trust this to fire.

Fields

§added: Vec<String>
§removed: Vec<String>
§turn_id: String
§

Notification

The model asked for the user’s attention with PushNotification.

Fields

§message: String
§status: Option<String>

"proactive" when the model sent it unprompted; None otherwise.

§turn_id: String
§

ProviderSwitched(ProviderSwitch)

A model call went to a different provider than the session’s call before it: from could not take it, or to can again.

§

AgentSpawned

A sub-agent was spawned.

Fields

§agent_id: String
§parent_turn: u32
§turn_id: String
§

AgentCompleted

A sub-agent completed.

Fields

§agent_id: String
§outcome: String
§turn_id: String
§

SubagentProgress

An event emitted inside a spawned sub-agent, re-emitted on the parent session’s channel so the host (IDE plugin / CLI) can render sub-agent activity live instead of staring at a long pause.

This is purely additive: the sub-agent’s text is still collected and returned as the Agent tool’s result for the model to read. Hosts that don’t understand this variant can ignore it and behave exactly as before.

Attribution: agent_label is stable for the whole lifetime of one sub-agent run, so a host can group every forwarded event under one collapsible node. parent_turn is the parent’s turn number (ToolContext::turn_no); the parent’s turn id is deliberately not carried here because runtime::turn does not thread it into ToolContext — transports that need it already know it from the enclosing turn (see the daemon’s run_turn stream frames).

Fields

§agent_label: String

Stable per-run label, e.g. "explore#3f2a1b7c".

§agent_session_id: String

The sub-agent’s own session id.

§agent_type: Option<String>

Named agent type, when the spawn selected one.

§parent_session_id: String

Parent session id, when the spawn site knew it ("" otherwise).

§parent_turn: u32

Parent turn number, 0 when unknown (same caveat as above).

§parent_tool_use_id: Option<String>

The parent’s Agent tool call this sub-agent is running for.

§task_id: Option<String>

The parent session’s task this sub-agent runs as.

§event: Box<AgentEvent>

The forwarded sub-agent event. Boxed so AgentEvent stays small.

§

TeamProgress

Team orchestration progress, emitted as each stage of a TeamCreate run starts and finishes — so a large team streams incremental progress instead of going silent until the whole scratchpad is returned as one tool result.

Fields

§team: String

Team name as given to TeamCreate.

§team_id: String

Generated team id (also the <project dir>/state/teams/<id>/ directory name).

§stage: String

Stage name.

§stage_index: usize

0-based stage index.

§stage_count: usize

Total number of stages in this team run.

§status: TeamStageStatus

Where this stage is in its lifecycle.

§members: Vec<String>

Labels of the members in this stage.

§failed: Vec<String>

Labels of members whose result was an error (only meaningful for Completed).

§

Error

The turn ended in failure.

Fields

§failure: TurnFailure
§turn_id: String
§persisted: bool

As TurnComplete::persisted: what the turn got to — the user’s message at least — is in the session’s log.

Trait Implementations§

Source§

impl Clone for AgentEvent

Source§

fn clone(&self) -> Self

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 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

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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