Skip to main content

Message

Struct Message 

Source
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: Role

Who 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: Value

Generic, 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

Source

pub fn user(text: impl Into<String>) -> Self

A plain-text user message.

Source

pub fn user_multimodal(content: Vec<ContentPart>) -> Self

A user message with arbitrary content parts (text, images).

Source

pub fn assistant(text: impl Into<String>) -> Self

A plain-text assistant message.

Source

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.

Source

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.

Source

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.

Source

pub fn with_thinking( self, thinking: impl Into<String>, signature: Option<String>, ) -> Self

Attach provider reasoning to this message — see Message::thinking.

Source

pub fn with_metadata(self, metadata: Value) -> Self

Attach extension metadata — see Message::metadata.

Source

pub fn with_external_actor(self, actor: ExternalActor) -> Self

Attribute a user message to an external channel actor.

Source

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).

Source

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 Clone for Message

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Message

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&str> for Message

Source§

fn from(text: &str) -> Self

Converts to this type from the input type.
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.

Source§

fn from(text: String) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Message

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Message

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.