#[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 more