#[non_exhaustive]pub enum StreamEvent {
Delta(String),
ToolCall {
id: String,
name: String,
arguments: String,
},
Reasoning(String),
Done {
reason: FinishReason,
usage: Option<Usage>,
},
}Expand description
An event in a streamed conversation reply.
One streamed reply = several StreamEvent::Delta /
StreamEvent::ToolCall increments + one closing StreamEvent::Done;
the caller concatenates the Deltas in order to get the full reply.
Stream termination semantics: on normal termination Done is always the
last success event on the stream; errors terminate the stream with an
Err item, and no events are produced after the error item.
The enum is #[non_exhaustive] (reserved for extension): matches must
include a wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Delta(String)
An incremental fragment of the reply content.
ToolCall
The model requests a tool call; argument fragments have already been
aggregated by the Provider into full JSON text, with fields matching
crate::ToolCall so the Agent can use them directly.
Fields
name: StringTool name, corresponding to the name in
Tool::schema.
Reasoning(String)
An incremental fragment of the model’s reasoning (thinking); the
vendor delivers it in fragments during the stream, and the Provider
forwards each fragment as it arrives (like StreamEvent::Delta) —
consumers concatenate them in order to get the full text.
Corresponds to the reasoning field of Message; the Agent must store
it in this turn’s message and carry it back verbatim in the history
(otherwise thinking models like DeepSeek / Qwen3 reject the request).
Done
The model finished its reply; the stream produces no more events after this.
Fields
reason: FinishReasonWhy the model ended its reply.
Trait Implementations§
Source§impl Clone for StreamEvent
impl Clone for StreamEvent
Source§fn clone(&self) -> StreamEvent
fn clone(&self) -> StreamEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StreamEvent
impl Debug for StreamEvent
Source§impl<'de> Deserialize<'de> for StreamEvent
impl<'de> Deserialize<'de> for StreamEvent
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>,
impl Eq for StreamEvent
Source§impl PartialEq for StreamEvent
impl PartialEq for StreamEvent
Source§impl Serialize for StreamEvent
impl Serialize for StreamEvent
impl StructuralPartialEq for StreamEvent
Auto Trait Implementations§
impl Freeze for StreamEvent
impl RefUnwindSafe for StreamEvent
impl Send for StreamEvent
impl Sync for StreamEvent
impl Unpin for StreamEvent
impl UnsafeUnpin for StreamEvent
impl UnwindSafe for StreamEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.