#[non_exhaustive]pub struct ToolExecutionResult { /* private fields */ }Expand description
The full structured result of a single tool execution.
This is what the dynamic tool boundary (ToolDyn)
produces and what flows through to the
StepEvent::ToolResult hook event. It
keeps the three concerns separate:
model_output: the text delivered to the model;outcome: the structuredToolOutcome;extensions: metadata never sent to the model.
Tool authors rarely build this directly — they return a ToolReturn and the
boundary assembles it. In a manual ToolDyn
implementation construct one with success /
failed / denied; read it back with the
model_output / outcome /
extensions accessors.
The fields are crate-private on purpose: Skipped is a
framework-only outcome (a hook Flow::Skip), and
there is no public constructor or setter that yields it — a tool that ran was
not skipped. See the ToolOutcome note.
Implementations§
Source§impl ToolExecutionResult
impl ToolExecutionResult
Sourcepub fn success(model_output: impl Into<String>) -> Self
pub fn success(model_output: impl Into<String>) -> Self
A successful result whose model output is model_output verbatim.
Sourcepub fn failed(model_output: impl Into<String>, failure: ToolFailure) -> Self
pub fn failed(model_output: impl Into<String>, failure: ToolFailure) -> Self
A failed result: model_output is the model-visible feedback, failure
the structured classification.
Sourcepub fn denied(model_output: impl Into<String>) -> Self
pub fn denied(model_output: impl Into<String>) -> Self
A Denied result: the tool refused the call (the
body did not run to completion). The tool-authored counterpart to a hook
Flow::Skip; see the
ToolOutcome note.
Sourcepub fn with_extensions(self, extensions: ToolResultExtensions) -> Self
pub fn with_extensions(self, extensions: ToolResultExtensions) -> Self
Attach result extensions, replacing any already set.
Sourcepub fn with_extension<E: Clone + WasmCompatSend + WasmCompatSync + 'static>(
self,
extension: E,
) -> Self
pub fn with_extension<E: Clone + WasmCompatSend + WasmCompatSync + 'static>( self, extension: E, ) -> Self
Insert a single value into the result extensions, returning the updated
result. The single-value counterpart to with_extensions,
mirroring ToolReturn::with_extension for manual
ToolDyn implementations.
Sourcepub fn model_output(&self) -> &str
pub fn model_output(&self) -> &str
The text delivered to the model as the tool result. Present even for a failure, so the model gets useful feedback (a handled error message).
Sourcepub fn outcome(&self) -> &ToolOutcome
pub fn outcome(&self) -> &ToolOutcome
The structured ToolOutcome of the call.
Sourcepub fn extensions(&self) -> &ToolResultExtensions
pub fn extensions(&self) -> &ToolResultExtensions
Metadata attached by the tool, surfaced to hooks/tracing but never sent to the model.
Trait Implementations§
Source§impl Clone for ToolExecutionResult
impl Clone for ToolExecutionResult
Source§fn clone(&self) -> ToolExecutionResult
fn clone(&self) -> ToolExecutionResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ToolExecutionResult
impl !UnwindSafe for ToolExecutionResult
impl Freeze for ToolExecutionResult
impl Send for ToolExecutionResult
impl Sync for ToolExecutionResult
impl Unpin for ToolExecutionResult
impl UnsafeUnpin for ToolExecutionResult
Blanket Implementations§
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> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
impl<T> DebuggableStorage for T
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 more