#[non_exhaustive]pub enum ToolLoopEvent {
Delta {
step: usize,
delta: TextDelta,
},
ToolResult {
step: usize,
call: ToolCall,
result: ToolResult,
},
StepFinished {
step: usize,
usage: StepUsage,
},
Done(ToolLoopOutcome),
}Expand description
One thing a streamed tool loop did (issue #859): the item type of
run_tool_loop_stream, produced in the order the work happened.
Within one step: every TextDelta as it arrived, then one result per
executed call, then the step’s StepUsage — the same bookkeeping, in
the same order, the buffered loop records into
ToolLoopOutcome::steps. A loop that finishes ends with exactly one
Self::Done; one that fails ends with the Err instead, and no
Done follows an error.
#[non_exhaustive]: the loop is new and what it can report will grow.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Delta
A TextDelta straight off the model’s stream, forwarded the
moment it arrived — including TextDelta::Reasoning, which the
completion rebuilt for the loop’s own decisions does not carry.
Fields
step: usizeThe step the delta belongs to: 0-based, the position its
StepUsage takes in ToolLoopOutcome::steps.
ToolResult
An executed tool call and the result the model will be shown — the
same ToolResult the buffered loop feeds back, a tool-level
failure included. Emitted after the call ran, before the next one
starts.
Fields
result: ToolResultWhat running it produced, or the error fed back instead.
StepFinished
A model call finished and this is what it cost — the same entry the
buffered loop appends to ToolLoopOutcome::steps. One per model
call, before that call’s tools run.
Fields
step: usizeThe step that finished, 0-based as in Self::Delta.
Done(ToolLoopOutcome)
The loop is over: the same outcome run_tool_loop returns for
the same run. Always the stream’s last item on success.