Skip to main content

MessageChunk

Enum MessageChunk 

Source
#[non_exhaustive]
pub enum MessageChunk { Delta(String), ToolCall { id: String, name: String, arguments: String, }, ToolResult { id: String, name: String, content: String, }, Done(RunSummary), Cancelled, }
Expand description

Message chunks for a streaming run — the streaming output of one run, sliced into pieces.

Delta / ToolCall / ToolResult are the streaming projection of the message record (text the model is generating, recorded Assistant tool requests, and returned ToolResult messages); Done / Cancelled are terminal markers. These are not “events” — real events are the application-level event abstraction AgentEvent(trait, where each Agent implementation defines its own event variants (the framework doesn’t anticipate them), flowing through an event pipeline.

§Reasoning

Reasoning produces no chunks: reasoning deltas from thinking models do not appear in this enum — matching on MessageChunk::Reasoning won’t compile, and that’s intentional. To surface reasoning, attach an EventChannel and subscribe to ReActEvent::Reasoning, or consume StreamEvent::Reasoning at the Provider layer.

The enum carries #[non_exhaustive] (reserved for extension): matches must include a wildcard arm.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Delta(String)

An increment of the reply text; increments within the same round are concatenated in order.

§

ToolCall

The model requested a tool call (the tool_calls of a recorded Assistant message).

Fields

§id: String

The id of this call, matching ToolCall::id in the recorded memory; used to pair multiple calls of the same tool within a round.

§name: String

The tool name.

§arguments: String

The arguments generated by the model (JSON text).

§

ToolResult

A tool execution completed (records a ToolResult message; on failure the content is the error text).

Fields

§id: String

The id of this execution, matching Message::ToolResult in the recorded memory; paired with the ToolCall id in the same round.

§name: String

The tool name.

§content: String

The execution result text (the error text on failure).

§

Done(RunSummary)

The run ended normally; carries the execution summary for this run (RunSummary); the stream produces no further chunks afterwards.

§

Cancelled

The run was cooperatively cancelled (via the CancellationToken passed to run/run_stream); terminal chunk, the stream produces no further chunks afterwards (no Done).

Trait Implementations§

Source§

impl Clone for MessageChunk

Source§

fn clone(&self) -> MessageChunk

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 MessageChunk

Source§

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

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

impl Eq for MessageChunk

Source§

impl PartialEq for MessageChunk

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MessageChunk

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more