#[non_exhaustive]pub enum MultiTurnStreamItem<R> {
StreamAssistantItem(StreamedAssistantContent<R>),
ToolExecutionStart {
tool_call: ToolCall,
internal_call_id: String,
},
StreamUserItem(StreamedUserContent),
CompletionCall(CompletionCall),
FinalResponse(PromptResponse),
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
StreamAssistantItem(StreamedAssistantContent<R>)
A streamed assistant content item — the content the model emitted:
text/reasoning deltas, tool-call deltas, and, when the model turn is
committed, the complete StreamedAssistantContent::ToolCall for each
tool call Rig routes to execution. Such a call is reported here whether or
not the tool body ultimately runs (a hook Flow::Skip still reports it);
it is not an execution-lifecycle event (see
ToolExecutionStart).
Two kinds of model tool call are not re-emitted as a complete
ToolCall item here (their arguments still stream as tool-call deltas):
a call rejected and handled by invalid-tool-call recovery (surfaced via
that recovery path), and a structured-output Tool-mode output-tool call,
which finalizes the run directly — its structured result is surfaced in
the FinalResponse rather than as a completed
ToolCall item.
ToolExecutionStart
Rig executed a tool call. Surfaced only for a tool whose body actually
ran (it passed its ToolCall hook checks) — never for a model tool call
that was dropped by a sibling’s termination, skipped by a hook
(Flow::Skip), or resolved by invalid-tool-call recovery. The tool batch
commits and surfaces atomically at every tool_concurrency (including
the sequential default): this event is surfaced together with its
ToolResult once the whole batch has settled successfully, so a run that
terminates mid-batch produces no ToolExecutionStart (hence no orphan
start without a result). Correlate with the model tool call and the result
via internal_call_id.
Fields
tool_call: ToolCallThe tool call as executed: the model’s call with any
Flow::RewriteArgs hook rewrite
applied (so a redaction rewrite is reflected here, not leaked). The
model’s original call is reported via
StreamAssistantItem.
internal_call_id: StringRig-generated id correlating this execution with the model tool call
(StreamedAssistantContent::ToolCall::internal_call_id) and the
resulting StreamedUserContent::ToolResult.
StreamUserItem(StreamedUserContent)
A streamed user content item: the result of an executed (or
hook-skipped) tool call. The tool batch commits and surfaces atomically at
every tool_concurrency (including the sequential default): results are
surfaced (in call order) only after the whole batch settles successfully —
a run that terminates mid-batch surfaces no successful tool results.
CompletionCall(CompletionCall)
Details for one successfully completed completion request made by this agent stream.
This is emitted when a provider call finishes. Usage is the provider’s final usage for that completion request when available; it is not incremental per streamed token.
match item {
MultiTurnStreamItem::CompletionCall(completion_call) => {
// Zero-valued usage means the provider reported no metrics.
if completion_call.usage.has_values() {
let context_tokens = completion_call.usage.input_tokens;
}
}
_ => {}
}FinalResponse(PromptResponse)
The final result from the stream: the unified PromptResponse shared
with the blocking surface.
Implementations§
Source§impl<R> MultiTurnStreamItem<R>
impl<R> MultiTurnStreamItem<R>
pub fn final_response( content: OneOrMany<AssistantContent>, aggregated_usage: Usage, ) -> Self
pub fn final_response_with_history( content: OneOrMany<AssistantContent>, aggregated_usage: Usage, history: Option<Vec<Message>>, ) -> Self
Trait Implementations§
Source§impl<R: Clone> Clone for MultiTurnStreamItem<R>
impl<R: Clone> Clone for MultiTurnStreamItem<R>
Source§fn clone(&self) -> MultiTurnStreamItem<R>
fn clone(&self) -> MultiTurnStreamItem<R>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<R: Debug> Debug for MultiTurnStreamItem<R>
impl<R: Debug> Debug for MultiTurnStreamItem<R>
Source§impl<'de, R> Deserialize<'de> for MultiTurnStreamItem<R>where
R: Deserialize<'de>,
impl<'de, R> Deserialize<'de> for MultiTurnStreamItem<R>where
R: Deserialize<'de>,
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>,
Auto Trait Implementations§
impl<R> Freeze for MultiTurnStreamItem<R>where
R: Freeze,
impl<R> RefUnwindSafe for MultiTurnStreamItem<R>where
R: RefUnwindSafe,
impl<R> Send for MultiTurnStreamItem<R>where
R: Send,
impl<R> Sync for MultiTurnStreamItem<R>where
R: Sync,
impl<R> Unpin for MultiTurnStreamItem<R>where
R: Unpin,
impl<R> UnsafeUnpin for MultiTurnStreamItem<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for MultiTurnStreamItem<R>where
R: UnwindSafe,
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> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
impl<T> DebuggableStorage for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more