pub enum AgentMessage {
System {
content: String,
timestamp: Option<u64>,
},
User {
content: UserContent,
timestamp: Option<u64>,
},
Assistant {
content: AssistantContent,
stop_reason: StopReason,
error_message: Option<String>,
timestamp: Option<u64>,
usage: Option<Usage>,
},
ToolResult {
tool_call_id: String,
tool_name: String,
content: ToolResultContent,
is_error: bool,
narration: Option<String>,
details: Option<Value>,
timestamp: Option<u64>,
},
Custom {
kind: String,
payload: Value,
timestamp: Option<u64>,
},
}Expand description
One message in the conversation transcript.
Discriminated by role. Each variant carries its own payload shape;
the loop pattern-matches, never field-walks.
Variants§
System
System prompt. Typically only one, at the head of the transcript.
User
User input. May be a single text block or rich blocks (text + images).
Assistant
Model output. Carries text, thinking blocks, and tool calls.
ToolResult
Output of a tool call. Always paired with a prior assistant message
that contains the corresponding ToolCall block.
Fields
content: ToolResultContentnarration: Option<String>Tool-side prose summary — the row-caption sentence the UI
renders (“Ran ls -la.”, “Wrote index.html (4 KB).”,
“Searched: rust async — 8 results.”). The loop fills this
from ToolResult::narration when the typed result is
appended to history; tools may set it deterministically
from their own structured signals. Optional for
backward-compatibility with persisted histories that
pre-date this field.
working_memory_anchor and other history-aware plugins
consume this in preference to walking the content blocks
for a preview; the model’s first-line peek of a densified
shell result is opaque metadata, while narration carries
the actual prose every other surface already shows.
details: Option<Value>Host-side structured payload carried from the tool’s
ToolResult::details. Stripped from provider wire formats
(the model sees content only) but preserved into history
so host-side plugins — delivery gates, artifact dispatchers,
UI projectors — can read structured fields without
text-grepping. Typed producers (create_slides,
create_website, publish) put canonical artifact metadata
here (html_url, artifacts: [...], …). None when the
tool returned no structured payload, or for messages
deserialized from histories persisted before this field
existed.
Custom
Escape hatch for app-specific message types (UI notifications, hidden runtime feedback, replay markers). The loop ignores these for tool dispatch but apps can route them through plugins or the event sink.
Trait Implementations§
Source§impl Clone for AgentMessage
impl Clone for AgentMessage
Source§fn clone(&self) -> AgentMessage
fn clone(&self) -> AgentMessage
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 AgentMessage
impl Debug for AgentMessage
Source§impl<'de> Deserialize<'de> for AgentMessage
impl<'de> Deserialize<'de> for AgentMessage
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 AgentMessage
impl PartialEq for AgentMessage
Source§fn eq(&self, other: &AgentMessage) -> bool
fn eq(&self, other: &AgentMessage) -> bool
self and other values to be equal, and is used by ==.