pub enum ChatMessage {
User {
content: String,
attachments: Vec<UserAttachment>,
},
Assistant {
text: Option<String>,
tool_calls: Vec<ToolInvocation>,
thinking: Option<AssistantThinking>,
usage: Option<HarnessUsage>,
},
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.
usage: Option<HarnessUsage>Provider-reported token tally for this assistant turn, when the
provider supplied one. Records the exact context size up to and
including this message, so context-size estimation can anchor on
a measured value and estimate only the messages appended after it.
None when the turn carried no reported usage.
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 more