pub struct Message {Show 17 fields
pub id: String,
pub role: Role,
pub content: String,
pub reasoning: Option<String>,
pub reasoning_signature: Option<String>,
pub content_parts: Option<Vec<MessagePart>>,
pub image_ocr: Option<Vec<ImageOcrResult>>,
pub phase: Option<MessagePhase>,
pub tool_calls: Option<Vec<ToolCall>>,
pub tool_call_id: Option<String>,
pub tool_success: Option<bool>,
pub compressed: bool,
pub compressed_by_event_id: Option<String>,
pub never_compress: bool,
pub compression_level: u8,
pub created_at: DateTime<Utc>,
pub metadata: Option<Value>,
}Expand description
A single message in a conversation.
Fields§
§id: String§role: Role§content: String§reasoning: Option<String>§reasoning_signature: Option<String>Provider-minted cryptographic signature covering reasoning, when the
turn’s thinking arrived as exactly ONE Anthropic thinking block (and no
redacted_thinking). Real Anthropic only accepts a replayed thinking
input block whose signature it minted itself over that exact text — so
this must never be set for reasoning from another provider, and must be
dropped if reasoning is ever rewritten (issue #520).
content_parts: Option<Vec<MessagePart>>§image_ocr: Option<Vec<ImageOcrResult>>§phase: Option<MessagePhase>§tool_calls: Option<Vec<ToolCall>>§tool_call_id: Option<String>§tool_success: Option<bool>§compressed: bool§compressed_by_event_id: Option<String>§never_compress: boolWhen true, this message is protected from context compression and will never be moved into the summary set.
compression_level: u8Progressive compression level: 0=uncompressed, 1=lightly compacted (head/tail), 2=heavily compacted. Applied at context preparation time, not persisted.
created_at: DateTime<Utc>§metadata: Option<Value>Implementations§
Source§impl Message
impl Message
pub fn user(content: impl Into<String>) -> Message
pub fn user_with_parts( content: impl Into<String>, parts: Vec<MessagePart>, ) -> Message
pub fn assistant( content: impl Into<String>, tool_calls: Option<Vec<ToolCall>>, ) -> Message
pub fn assistant_with_reasoning( content: impl Into<String>, tool_calls: Option<Vec<ToolCall>>, reasoning: Option<String>, ) -> Message
Sourcepub fn with_reasoning_signature(self, signature: Option<String>) -> Message
pub fn with_reasoning_signature(self, signature: Option<String>) -> Message
Attach a provider-minted signature covering reasoning (see the field
doc). Intended for the builder position right after
Message::assistant_with_reasoning.
pub fn tool_result( tool_call_id: impl Into<String>, content: impl Into<String>, ) -> Message
pub fn tool_result_with_status( tool_call_id: impl Into<String>, content: impl Into<String>, success: bool, ) -> Message
Sourcepub fn tool_result_with_images(
tool_call_id: impl Into<String>,
content: impl Into<String>,
success: bool,
images: Vec<ToolResultImage>,
) -> Message
pub fn tool_result_with_images( tool_call_id: impl Into<String>, content: impl Into<String>, success: bool, images: Vec<ToolResultImage>, ) -> Message
Tool-result message carrying both text and images (e.g. an MCP
screenshot). The text goes in content (token-capped/persisted as
usual); each image becomes a MessagePart::ImageUrl data URL in
content_parts, so vision-capable providers receive the real image.