pub enum MultiTurnStreamItem {
StreamAssistantItem(StreamedAssistantContent),
ToolExecutionCommitted {
tool_call: ToolCall,
internal_call_id: String,
},
StreamUserItem(StreamedUserContent),
CompletionCall(CompletionCall),
ModelTurnRetried {
turn: usize,
},
FinalResponse(PromptResponse),
}Variants§
StreamAssistantItem(StreamedAssistantContent)
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 MultiTurnStreamItem
impl MultiTurnStreamItem
Sourcepub fn final_response(
content: Vec<AssistantContent>,
aggregated_usage: Usage,
) -> Self
pub fn final_response( content: Vec<AssistantContent>, aggregated_usage: Usage, ) -> Self
Build a FinalResponse item from final-turn content, applying the
run-finalization shaping of final_response_from_content (#1928).
The one public entry point to that shaping, for mocks and adapters
that synthesize final items outside the drive loop.
Trait Implementations§
Source§impl Clone for MultiTurnStreamItem
impl Clone for MultiTurnStreamItem
Source§fn clone(&self) -> MultiTurnStreamItem
fn clone(&self) -> MultiTurnStreamItem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more