#[non_exhaustive]pub enum MultiTurnStreamItem {
StreamAssistantItem(Item<StreamEvent>),
ToolCall {
tool_call: ToolCall,
},
ToolExecutionStarted {
tool_call: ToolCall,
},
ToolResultItem {
tool_result: ToolResult,
index: usize,
count: usize,
},
ToolExecutionCommitted {
tool_call: ToolCall,
},
ToolResult {
tool_result: ToolResult,
},
CompletionCall(CompletionCall),
ModelTurnRetried {
turn: usize,
},
FinalResponse(PromptResponse),
}agent only.Expand description
One item of a streamed run: a provider stream event, a committed tool
call, a lifecycle marker, or the run’s final response. An item reads back
from its serialized form on its own, without checking its order against
the items around it; StreamRecord::parse
checks a run’s provider stream items.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
StreamAssistantItem(Item<StreamEvent>)
A provider stream item containing model-emitted content: part
starts and ends, text and reasoning fragments, a tool call’s
argument fragments as they stream (a call to a tool the turn does not
allow is held for its resolution), and unmodeled passthrough
payloads. A call’s end carries the validated call; the same call id
is reported again as ToolCall once history holds it.
ToolCall
A tool call committed to the run’s history, in commit order.
The stream’s tool items are a projection of committed history
(project): every call history holds is
reported, and later answered by a ToolResult,
whether it ran, a hook skipped it, or invalid-call recovery or an
output reprompt answered it; a run resumed mid-batch reports the batch’s
calls again (projection_start).
It is not an execution-lifecycle event
(see ToolExecutionCommitted). A
structured-output Tool-mode output-tool call that finalizes the run is
committed as text, so it is reported in the
FinalResponse instead.
Fields
ToolExecutionStarted
A tool call starts: Rig dispatches it now, before its dispatch
hooks and its body run. The call goes on only once the stream’s
consumer has taken this item, so a slow consumer delays the call. A
RunEvents feed takes it into its buffer, so there the call may run
before the feed’s reader sees it.
One item per dispatched call, after the turn’s
ToolCall items and before the batch’s commits and
results: in call order when calls run one at a time, in start order
under tool_concurrency. A call a dispatch hook skips still starts.
A call answered by invalid-call recovery, or dropped because a
sibling ended the run, never starts. A start is not a commit: a
batch that fails surfaces its starts but no commits or results.
Fields
ToolResultItem
One item of a tool’s accepted output, reported as soon as the
call’s outcome hooks accept it, without waiting for the rest of the
batch. The call goes on only once the stream’s consumer has taken the
item, as for ToolExecutionStarted.
An output that is exactly one JSON array is reported one element at a
time, each as one JSON block (an empty array reports nothing); any
other output is one item holding all its blocks. Text is never
reparsed as JSON. Items come in completion order under
tool_concurrency, so items of different calls may interleave: group
them by tool_result.call. Every started call that answers reports its items,
a hook-skipped one included; a call answered by invalid-call recovery
reports none. An item is not a commit: items stay reported when a
sibling later fails the batch, a call already running when a sibling
fails still reports its items as it finishes, and the committed
ToolResult still follows a batch that settles.
Show these for progress; record only the ToolResult.
Fields
tool_result: ToolResultThis item’s content, with the call id, name and error flag of the result the batch commits for the call.
ToolExecutionCommitted
Confirmation that Rig executed and committed a tool call. It is
surfaced together with its ToolResult only after the whole batch
settles successfully; the live start is
ToolExecutionStarted.
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 the call’s id.
Fields
tool_call: ToolCallThe tool call as executed: the model’s call with any
DispatchAction::Patch hook rewrite
applied (so a redaction rewrite is reflected here, not leaked). The
model’s original call is reported via
StreamAssistantItem.
ToolResult
A tool result committed to the run’s history, answering a reported
ToolCall. 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. The live output is
ToolResultItem.
Fields
tool_result: ToolResultThe result; tool_result.call is the id of the call it answers.
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.
use rig_agent::agent::MultiTurnStreamItem;
fn input_tokens(item: &MultiTurnStreamItem) -> Option<u64> {
match item {
MultiTurnStreamItem::CompletionCall(call) => call.usage.input_tokens,
_ => None,
}
}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.
Terminal for the run: no retry, further turn, or tool execution follows.
This item is the stream-side
counterpart of the on_run_settled hook’s success outcome. Error
termination surfaces as the stream’s Err item instead, which is
equally terminal.
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 moreSource§impl Debug for MultiTurnStreamItem
impl Debug for MultiTurnStreamItem
Source§impl<'de> Deserialize<'de> for MultiTurnStreamItem
impl<'de> Deserialize<'de> for MultiTurnStreamItem
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<MultiTurnStreamItem, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<MultiTurnStreamItem, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<LiveTool> for MultiTurnStreamItem
impl From<LiveTool> for MultiTurnStreamItem
Source§fn from(live: LiveTool) -> MultiTurnStreamItem
fn from(live: LiveTool) -> MultiTurnStreamItem
Source§impl From<Surfaced> for MultiTurnStreamItem
The one mapping from what the engine surfaces directly; tool items are
built only from committed history.
impl From<Surfaced> for MultiTurnStreamItem
The one mapping from what the engine surfaces directly; tool items are built only from committed history.
Source§fn from(surfaced: Surfaced) -> MultiTurnStreamItem
fn from(surfaced: Surfaced) -> MultiTurnStreamItem
Source§impl Serialize for MultiTurnStreamItem
impl Serialize for MultiTurnStreamItem
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Forget for MultiTurnStreamItem
impl Freeze for MultiTurnStreamItem
impl Move for MultiTurnStreamItem
impl RefUnwindSafe for MultiTurnStreamItem
impl Send for MultiTurnStreamItem
impl Sync for MultiTurnStreamItem
impl Unpin for MultiTurnStreamItem
impl UnsafeUnpin for MultiTurnStreamItem
impl UnwindSafe for MultiTurnStreamItem
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<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> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
Source§fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> ToBoltType for Twhere
T: Serialize,
impl<T> ToBoltType for Twhere
T: Serialize,
Source§fn to_bolt_type(&self) -> BoltType
fn to_bolt_type(&self) -> BoltType
BoltType::Null for values that fail to
serialize or fall outside Bolt’s numeric range.