pub enum AgentEvent {
Show 22 variants
AgentStart,
TurnStart,
MessageStart {
message: AgentMessage,
},
MessageUpdate {
message: AgentMessage,
},
MessageEnd {
message: AgentMessage,
},
ToolExecutionStart {
call_id: String,
name: String,
},
ToolExecutionUpdate {
call_id: String,
name: String,
partial: String,
},
ToolExecutionEnd {
call_id: String,
name: String,
output: String,
is_error: bool,
diff: Option<String>,
path: Option<String>,
duration_ms: Option<u64>,
},
TurnEnd {
message: AgentMessage,
},
Compaction {
summarized: usize,
kept: usize,
},
CompactionSkipped {
reason: String,
},
Retrying {
attempt: u32,
max: u32,
reason: String,
},
MessageReceived {
from: SessionId,
content: String,
},
Error {
message: String,
},
Ack,
Stopped {
stop_reason: StopReason,
},
SideAnswer {
text: String,
usage: Option<Usage>,
},
History {
messages: Vec<AgentMessage>,
},
Sessions {
sessions: Vec<SessionInfo>,
},
Spawned {
worker: SessionId,
},
Todo {
todos: Vec<TodoItem>,
},
AgentEnd,
}Variants§
AgentStart
TurnStart
MessageStart
Fields
message: AgentMessageMessageUpdate
Fields
message: AgentMessageMessageEnd
Fields
message: AgentMessageToolExecutionStart
ToolExecutionUpdate
ToolExecutionEnd
Fields
diff: Option<String>UI-only unified diff (see ToolOutput::diff); absent when there is
nothing to show, or on an older peer that predates the field.
TurnEnd
Fields
message: AgentMessageCompaction
Auto-compaction summarized summarized older messages, keeping kept.
CompactionSkipped
Best-effort auto-compaction was attempted (the context was near the
ceiling) but did NOT complete — a summarizer/stream failure. The run
continues. Deliberately NOT AgentEvent::Error, whose contract is a
stream-level failure: a TUI renders Error as a failed run, so routing
a best-effort compaction miss through it would falsely mark the run
failed. reason is the summarizer’s error text, for display only — never
fed back to the model and never fatal. Purely additive on the wire
({"type":"compaction_skipped","reason":…}), so
crate::protocol::PROTOCOL_VERSION need not bump.
Retrying
The adapter retried a failed connect after a transient error.
MessageReceived
A peer delivered a message to this session (Request::Notify/
Interrupt/Wake). from is the sender’s address (§5.2 — the human is
crate::protocol::USER); streamed, so a UI can surface an inbound
message. Not a reply.
Error
Stream-level failure. A fatal-class failure (bad request, auth, schema)
ends the run with StopReason::Error; a transient-class failure that
exhausted its retries (or landed mid-stream) is fed back to the model
and the loop continues, still bounded by a consecutive-error cap.
Ack
Reply: a request with no richer answer succeeded (e.g. SetModel).
Never streamed — it answers one request, correlated by the transport
(an in-process reply channel today, the envelope’s reply_to on the
wire).
Stopped
Reply: the run finished, with why it stopped. Answers a Submit. Never
streamed (see AgentEvent::Ack).
Fields
stop_reason: StopReasonSideAnswer
Reply: a tool-free side answer to a Request::SideAsk (/btw). Never
streamed (see AgentEvent::Ack). Carries the answer text and the
turn’s usage (for a /usage-style readout); styling is the front-end’s.
History
Reply: the conversation so far, answering a Request::GetHistory. Never
streamed (see AgentEvent::Ack).
Fields
messages: Vec<AgentMessage>Sessions
Reply: the sessions a server serves, in serve order (root first), each
with the model the server knows for it (crate::protocol::SessionInfo).
Answers a crate::protocol::Request::ListSessions. Never streamed (see
AgentEvent::Ack).
Fields
sessions: Vec<SessionInfo>Spawned
Reply: a peer defined a worker and returns its address, answering a
crate::protocol::Request::Define. Never streamed (see
AgentEvent::Ack).
The field is worker, not id: the envelope already carries a top-level
id (the request it replies to), and a flattened duplicate key would not
deserialize.
Todo
The todo checklist, streamed on every write (mirror Compaction /
Retrying: a plain state payload the UI reduces). The field is todos,
not id: the envelope already carries a top-level id and a flattened
duplicate key would not deserialize.