pub struct ToolExecutionError { /* private fields */ }Expand description
One public envelope for every tool execution failure.
It carries normalized policy fields, separate operator-facing diagnostics
and model-visible output, and an optional concrete source that can be
downcast. Explicit constructors use the diagnostic message as model-visible
output so deliberately authored validation failures remain actionable.
Self::from_error instead treats an arbitrary source as operator-only and
exposes safe kind-level feedback. Use Self::with_model_feedback or
Self::with_model_output to provide a purpose-built presentation.
Implementations§
Source§impl ToolExecutionError
impl ToolExecutionError
Sourcepub fn report(&self) -> ErrorReport
pub fn report(&self) -> ErrorReport
The wire form of this error.
Source§impl ToolExecutionError
impl ToolExecutionError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether the tool may reasonably be re-run: the explicit override when
one was set, else the kind’s own default
(ToolErrorKind::default_retryable); a kind that leaves it to the
tool (None) is not retryable on the wire.
Source§impl ToolExecutionError
impl ToolExecutionError
Sourcepub fn invalid_args(message: impl Into<String>) -> Self
pub fn invalid_args(message: impl Into<String>) -> Self
Invalid arguments.
Sourcepub fn permission_denied(message: impl Into<String>) -> Self
pub fn permission_denied(message: impl Into<String>) -> Self
An authorization or permission failure.
This is an ordinary execution error. Use Self::refused when the tool
intentionally declines the operation so hooks and telemetry can preserve
the refusal as a distinct disposition.
Sourcepub fn rate_limited(message: impl Into<String>) -> Self
pub fn rate_limited(message: impl Into<String>) -> Self
Rate limit.
Source§impl ToolExecutionError
impl ToolExecutionError
Sourcepub fn new(kind: ToolErrorKind, message: impl Into<String>) -> Self
pub fn new(kind: ToolErrorKind, message: impl Into<String>) -> Self
Construct an error with an explicit normalized kind.
Sourcepub fn refused(message: impl Into<String>) -> Self
pub fn refused(message: impl Into<String>) -> Self
An intentional, tool-authored refusal.
Refusals use the normalized ToolErrorKind::PermissionDenied kind but
remain distinct from permission failures in ToolResult.
Sourcepub fn from_error<E>(error: E) -> Self
pub fn from_error<E>(error: E) -> Self
Build a safely presented Other error from a concrete source.
The source’s display string remains in Self::message, while the model
sees stable ToolErrorKind::Other feedback. Native targets retain the
downcastable source; WASM drops it. An existing ToolExecutionError
retains its classification and presentation.
Sourcepub fn with_model_feedback(self, feedback: impl Into<String>) -> Self
pub fn with_model_feedback(self, feedback: impl Into<String>) -> Self
Replace the model-visible output with literal text feedback.
Sourcepub fn with_model_output(self, output: ToolOutput) -> Self
pub fn with_model_output(self, output: ToolOutput) -> Self
Replace the model-visible output with canonical JSON or multimodal content.
Sourcepub fn with_retryable(self, retryable: bool) -> Self
pub fn with_retryable(self, retryable: bool) -> Self
Override the retryability hint.
Sourcepub fn with_http_status(self, status: u16) -> Self
pub fn with_http_status(self, status: u16) -> Self
Attach an HTTP status.
Sourcepub fn with_source<E>(self, source: E) -> Self
pub fn with_source<E>(self, source: E) -> Self
Preserve a concrete source for later downcasting.
Browser wasm keeps no source (see the field): the call is accepted and the source dropped, so tool code stays target-independent.
Sourcepub const fn kind(&self) -> ToolErrorKind
pub const fn kind(&self) -> ToolErrorKind
Normalized kind.
Sourcepub fn model_feedback(&self) -> Option<&str>
pub fn model_feedback(&self) -> Option<&str>
Literal model feedback, when the presentation is exactly one plain text block.
Use Self::model_output for JSON or multimodal feedback.
Sourcepub fn model_output(&self) -> &ToolOutput
pub fn model_output(&self) -> &ToolOutput
Canonical model-visible presentation for this error.
Sourcepub const fn http_status(&self) -> Option<u16>
pub const fn http_status(&self) -> Option<u16>
HTTP status.
Sourcepub const fn is_refusal(&self) -> bool
pub const fn is_refusal(&self) -> bool
Whether the tool intentionally refused the operation.
Sourcepub fn downcast_ref<E>(&self) -> Option<&E>
pub fn downcast_ref<E>(&self) -> Option<&E>
Downcast the concrete source to E.
Trait Implementations§
Source§impl Clone for ToolExecutionError
impl Clone for ToolExecutionError
Source§impl Debug for ToolExecutionError
impl Debug for ToolExecutionError
Source§impl<'de> Deserialize<'de> for ToolExecutionError
impl<'de> Deserialize<'de> for ToolExecutionError
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>,
Source§impl Display for ToolExecutionError
impl Display for ToolExecutionError
Source§impl Error for ToolExecutionError
impl Error for ToolExecutionError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<&ToolExecutionError> for ErrorReport
impl From<&ToolExecutionError> for ErrorReport
Source§fn from(error: &ToolExecutionError) -> Self
fn from(error: &ToolExecutionError) -> Self
Source§impl From<ToolContextError> for ToolExecutionError
impl From<ToolContextError> for ToolExecutionError
Source§fn from(error: ToolContextError) -> Self
fn from(error: ToolContextError) -> Self
Source§impl From<ToolExecutionError> for ErrorReport
impl From<ToolExecutionError> for ErrorReport
Source§fn from(error: ToolExecutionError) -> Self
fn from(error: ToolExecutionError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for ToolExecutionError
impl !UnwindSafe for ToolExecutionError
impl Freeze for ToolExecutionError
impl Send for ToolExecutionError
impl Sync for ToolExecutionError
impl Unpin for ToolExecutionError
impl UnsafeUnpin for ToolExecutionError
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 moreSource§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> 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> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.