pub struct Message {
pub role: Role,
pub content: Vec<ContentPart>,
pub tool_calls: Vec<ToolCall>,
pub tool_call_id: Option<String>,
pub thinking: Option<String>,
pub thinking_signature: Option<String>,
pub metadata: Value,
pub external_actor: Option<ExternalActor>,
}Expand description
One message in a conversation.
This is both what drivers send to a provider and what replaying the event log reconstructs, so anything that must survive a resume lives here rather than beside it.
Fields§
§role: RoleWho produced it.
content: Vec<ContentPart>Content parts, in order. Text-only messages carry a single Text
part (or none, for an empty message) — see Message::text.
tool_calls: Vec<ToolCall>Tool calls requested by an assistant message.
tool_call_id: Option<String>For Role::Tool messages: the call this result answers.
thinking: Option<String>Provider reasoning (“extended thinking”) text, when the model emitted
a reasoning block. First-class because it is not everruns-specific
(OpenAI reasoning, Anthropic thinking) and it must round-trip back to
the provider on subsequent turns for the exchange to stay valid —
which an out-of-band store can’t guarantee (the driver only ever sees
Message). Empty for the common no-reasoning case.
thinking_signature: Option<String>Opaque signature the provider requires to accept a replayed thinking
block (e.g. Anthropic’s signature). Paired with Message::thinking.
metadata: ValueGeneric, serializable extension hatch — the message analogue of
crate::event::EventData::Custom. Everruns-flavored richness a
adopting host owns (execution phase, narration hints, provider
extras) rides here instead of growing typed core fields. Null for
the common case.
external_actor: Option<ExternalActor>External identity of the user who produced this message.
Kept separate from generic metadata because correct multi-actor model context depends on it: drivers must be able to distinguish speakers.
Implementations§
Source§impl Message
impl Message
Sourcepub fn user_multimodal(content: Vec<ContentPart>) -> Self
pub fn user_multimodal(content: Vec<ContentPart>) -> Self
A user message with arbitrary content parts (text, images).
Sourcepub fn assistant_with_calls(
text: impl Into<String>,
tool_calls: Vec<ToolCall>,
) -> Self
pub fn assistant_with_calls( text: impl Into<String>, tool_calls: Vec<ToolCall>, ) -> Self
An assistant message requesting tools, with optional accompanying
text. An empty text is normal: models often answer with calls alone.
Sourcepub fn tool_result(call_id: impl Into<String>, text: impl Into<String>) -> Self
pub fn tool_result(call_id: impl Into<String>, text: impl Into<String>) -> Self
A tool’s result, addressed back to the call it answers. The turn loop
builds these from tool.completed events, so a resumed session
reconstructs them identically.
Sourcepub fn tool_result_with_parts(
call_id: impl Into<String>,
text: impl Into<String>,
parts: impl IntoIterator<Item = ContentPart>,
) -> Self
pub fn tool_result_with_parts( call_id: impl Into<String>, text: impl Into<String>, parts: impl IntoIterator<Item = ContentPart>, ) -> Self
A tool result carrying extra content parts (images) after its text —
see crate::tool::ToolOutput::parts. Equivalent to
Message::tool_result when parts is empty.
Sourcepub fn with_thinking(
self,
thinking: impl Into<String>,
signature: Option<String>,
) -> Self
pub fn with_thinking( self, thinking: impl Into<String>, signature: Option<String>, ) -> Self
Attach provider reasoning to this message — see Message::thinking.
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
Attach extension metadata — see Message::metadata.
Sourcepub fn with_external_actor(self, actor: ExternalActor) -> Self
pub fn with_external_actor(self, actor: ExternalActor) -> Self
Attribute a user message to an external channel actor.
Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
The concatenation of every text part, in order. Empty if the message has no text content (e.g. an image-only message, or a tool-call-only assistant message).
Sourcepub fn is_text_only(&self) -> bool
pub fn is_text_only(&self) -> bool
True if every content part is text (no images) — the common case, and the signal drivers use to decide whether they can send a plain string on the wire instead of a content-part array.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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 From<String> for Message
So a turn can be opened with either a string or a whole message — see
Session::run. Text is by far the common case and should stay a one-liner;
an image the model is asked to look at should not need a different method.
impl From<String> for Message
So a turn can be opened with either a string or a whole message — see
Session::run. Text is by far the common case and should stay a one-liner;
an image the model is asked to look at should not need a different method.