pub enum ChatMessage {
User {
content: String,
attachments: Vec<UserAttachment>,
},
Assistant {
text: Option<String>,
tool_calls: Vec<ToolInvocation>,
thinking: Option<AssistantThinking>,
},
Tool {
tool_call_id: String,
content: String,
is_error: bool,
attachments: Vec<UserAttachment>,
},
}Expand description
One conversation entry as seen by the model. Mirrors the
system / user / assistant / tool set OpenAI chat/completions expects.
Anthropic’s Messages API uses a different shape (tool_use / tool_result
content blocks instead of separate tool role) but consumes the same
ChatMessage history — the projection lives in the per-provider
model client, keeping the harness loop provider-agnostic.
Variants§
User
Fields
attachments: Vec<UserAttachment>Non-text attachments (images today; file_id / documents later).
Renders as additional content blocks alongside the content
text on the wire — projection per provider in §8 / §9.
Assistant
Assistant turn. May carry any combination of: a thinking block
(Anthropic extended thinking), final text, and one+ tool calls.
All three render into the assistant message’s content array on
the Anthropic wire; OpenAI uses tool_calls for tool calls and
ignores thinking entirely.
Fields
tool_calls: Vec<ToolInvocation>thinking: Option<AssistantThinking>Thinking block to round-trip verbatim. None for OpenAI /
Anthropic-without-extended-thinking turns.
Tool
Tool response paired by tool_call_id. content is the
serialized tool output (model side sees a string regardless of
the underlying JSON shape). attachments carries structured
non-text content the tool produced — e.g. a screenshot MCP tool
returning an image. Only providers with a tool-content array
(Anthropic) surface these on the wire; OpenAI tool role is
strictly string-typed, so attachments degrade to a placeholder
in the content string there.
Trait Implementations§
Source§impl Clone for ChatMessage
impl Clone for ChatMessage
Source§fn clone(&self) -> ChatMessage
fn clone(&self) -> ChatMessage
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 ChatMessage
impl Debug for ChatMessage
Source§impl<'de> Deserialize<'de> for ChatMessage
impl<'de> Deserialize<'de> for ChatMessage
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 ChatMessage
impl PartialEq for ChatMessage
Source§fn eq(&self, other: &ChatMessage) -> bool
fn eq(&self, other: &ChatMessage) -> bool
self and other values to be equal, and is used by ==.