Skip to main content

MultiTurnStreamItem

Enum MultiTurnStreamItem 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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: ToolCall

The 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: String

Rig-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>

Source

pub fn final_response( content: OneOrMany<AssistantContent>, aggregated_usage: Usage, ) -> Self

Source

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>

Source§

fn clone(&self) -> MultiTurnStreamItem<R>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<R: Debug> Debug for MultiTurnStreamItem<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<R> Serialize for MultiTurnStreamItem<R>
where R: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneDebuggableStorage for T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CloneableStorage for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> DebuggableStorage for T
where T: Any + Send + Sync + Debug,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more