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).
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.
ToolUseStart
The model has started writing a tool call. ToolUse with the same
id follows once its arguments are complete.
ToolArgsDelta
A raw fragment of a started tool call’s arguments (high frequency).
The fragments concatenate to the JSON that ToolUse carries parsed.
ToolUse
Model requested a tool call.
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
ToolResult
Tool execution completed.
Fields
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
task_id: Option<String>The background task whose sub-agent asks, when one does. Its question outlives the turn it happened to arrive during.
origin: Option<PromptOrigin>The plugin command whose sub-call this is; None for the model’s own.
QuestionPrompt
The model asked the user something (AskUserQuestion) and waits for
the host’s answer.
Fields
options: Vec<ElicitOption>Offered answers; empty means free-form.
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
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
resolution: PromptResolutionreason: 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
HostToolCallResolved
The host call call_id is no longer open. Emitted once per call.
HostHookCall
A hook host registered fires: the host answers it with call_id.
input is the payload a command hook reads on stdin.
Fields
HostHookCallResolved
The hook call call_id is no longer open. Emitted once per call.
TurnStart
A turn has started. Every TurnStart is followed by exactly one
TurnComplete or Error with the same turn_id.
StepStart
The turn is about to call the model. step counts the turn’s model
calls from 0.
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.
StepEnd
The model call step has finished and its reply — plus the results of
the tools it asked for — is in the transcript.
Fields
seq: u64How 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
usage: UsageEvery 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: UsageBreakdownmessage: Option<String>Why the turn was stopped, when whatever stopped it said so — a
hook’s message, for instance.
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.
truncated: boolA 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.
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.
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.
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.
SystemInit
System initialization completed.
System
System notification.
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
trigger: CompactCauseCompactEnded
The compaction a CompactStarted announced left the history as it was.
CompactAction
The history was compacted or trimmed.
Fields
SessionChanged
Session was changed (via set_session_id).
SessionPersisted
Session was persisted to disk.
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.
Notification
The model asked for the user’s attention with PushNotification.
Fields
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.
AgentCompleted
A sub-agent completed.
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
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
status: TeamStageStatusWhere this stage is in its lifecycle.
Error
The turn ended in failure.