pub struct ToolResult { /* private fields */ }Expand description
The single structured execution view used by dispatch, hooks, and telemetry.
Each result has exactly one disposition. The tagged state is private so tool
authors keep returning ordinary Result values while runtime callers use
the stable query methods on this type.
Implementations§
Source§impl ToolResult
impl ToolResult
Sourcepub fn success(output: ToolOutput) -> Self
pub fn success(output: ToolOutput) -> Self
Creates a successful canonical tool result.
Sourcepub fn failed(error: ToolExecutionError) -> Self
pub fn failed(error: ToolExecutionError) -> Self
Creates a failed or refused canonical tool result.
Sourcepub fn skipped(reason: impl Into<String>) -> Self
pub fn skipped(reason: impl Into<String>) -> Self
Creates a result for a call skipped by runtime policy.
Sourcepub fn with_output(self, output: ToolOutput) -> Self
pub fn with_output(self, output: ToolOutput) -> Self
The same result with its model-visible output replaced, keeping its disposition: a success or a skip carries the new output; a failure or refusal keeps its error and presents the new output to the model.
Sourcepub fn output(&self) -> &ToolOutput
pub fn output(&self) -> &ToolOutput
Current model-visible output, including replacements made by Self::with_output.
Sourcepub fn error(&self) -> Option<&ToolExecutionError>
pub fn error(&self) -> Option<&ToolExecutionError>
Structured execution error, if execution failed.
Intentional refusals are available through Self::refusal instead.
Sourcepub fn refusal(&self) -> Option<&ToolExecutionError>
pub fn refusal(&self) -> Option<&ToolExecutionError>
Structured refusal details, if the tool intentionally declined the call.
This is mutually exclusive with Self::error.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Whether the tool completed successfully.
Sourcepub fn is_error(&self) -> bool
pub fn is_error(&self) -> bool
Whether execution failed.
An intentional refusal is not an execution error; inspect
Self::is_refused instead.
Sourcepub fn is_skipped(&self) -> bool
pub fn is_skipped(&self) -> bool
Whether the framework skipped execution before the tool body ran.
Sourcepub fn is_refused(&self) -> bool
pub fn is_refused(&self) -> bool
Whether a tool refused execution.
Sourcepub fn is_error_kind(&self, kind: ToolErrorKind) -> bool
pub fn is_error_kind(&self, kind: ToolErrorKind) -> bool
Whether this is an error of exactly kind.
A refusal does not match, even though its envelope uses the normalized
ToolErrorKind::PermissionDenied kind.
Sourcepub fn into_result(self) -> Result<ToolOutput, ToolExecutionError>
pub fn into_result(self) -> Result<ToolOutput, ToolExecutionError>
Converts success or skipped dispositions to Ok(output) and errors or
refusals to Err(error).
Sourcepub fn status_name(&self) -> &'static str
pub fn status_name(&self) -> &'static str
Stable telemetry disposition: success, error, denied, or skipped.
Trait Implementations§
Source§impl Clone for ToolResult
impl Clone for ToolResult
Source§impl Debug for ToolResult
impl Debug for ToolResult
Source§impl<'de> Deserialize<'de> for ToolResult
impl<'de> Deserialize<'de> for ToolResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl !RefUnwindSafe for ToolResult
impl !UnwindSafe for ToolResult
impl Freeze for ToolResult
impl Send for ToolResult
impl Sync for ToolResult
impl Unpin for ToolResult
impl UnsafeUnpin for ToolResult
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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