#[non_exhaustive]pub enum MultiTurnStreamItem<R> {
StreamAssistantItem(StreamedAssistantContent<R>),
ToolExecutionCommitted {
tool_call: ToolCall,
internal_call_id: String,
},
StreamUserItem(StreamedUserContent),
CompletionCall(CompletionCall),
ModelTurnRetried {
turn: usize,
},
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 skip still reports it);
it is not an execution-lifecycle event (see
ToolExecutionCommitted).
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.
ToolExecutionCommitted
Confirmation that Rig executed and committed a tool call. This is not
a real-time start notification: it is surfaced together with its
ToolResult only after the whole batch settles successfully. Use tool
hooks for live host-side start/result observation.
This item is emitted only for a tool whose body actually ran (it passed
its ToolCall hook checks), never for a call dropped by a sibling’s
termination, skipped by a hook, or resolved by invalid-call recovery.
Correlate it with the model call and result through internal_call_id.
Fields
tool_call: ToolCallThe tool call as executed: the model’s call with any
ToolCallAction::Rewrite 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;
}
}
_ => {}
}ModelTurnRetried
The completed model turn was rejected by a hook for retry.
Text and reasoning deltas emitted for this turn were provisional. A
consumer should discard or visually reset output associated with turn.
A subsequent attempt is made only if the run’s total model-call budget
permits it.
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 more