pub enum ToolError {
NotFound(String),
InvalidArgs {
tool: String,
message: String,
},
Unavailable {
tool: String,
reason: String,
},
Timeout {
tool: String,
seconds: u64,
},
PermissionDenied(String),
ExecutionFailed {
tool: String,
message: String,
},
CapabilityDenied {
tool: String,
code: String,
message: String,
suppression_key: Option<String>,
suggested_tool: Option<String>,
suggested_action: Option<String>,
},
ContentMismatch {
tool: String,
path: String,
message: String,
},
Other(String),
}Expand description
Tool-specific errors with retry strategy metadata.
These are converted to JSON and sent back to the LLM so it can self-correct (e.g. fix a bad path, retry with different args).
Variants§
NotFound(String)
InvalidArgs
Timeout
PermissionDenied(String)
ExecutionFailed
CapabilityDenied
Fields
ContentMismatch
Content-mismatch error — the tool’s expected content (e.g. old_string) did not
match the actual file contents, or the file changed between a read and a write
(TOCTOU). The message field embeds a 600-char file preview when available so the
model can retry with corrected arguments without an extra read_file round-trip.
Numeric code: 1008 (content_mismatch).
Fields
Other(String)
Implementations§
Source§impl ToolError
impl ToolError
pub fn capability_denied( tool: impl Into<String>, code: impl Into<String>, message: impl Into<String>, ) -> Self
pub fn with_suppression_key(self, suppression_key: impl Into<String>) -> Self
pub fn with_suggested_tool(self, suggested_tool: impl Into<String>) -> Self
pub fn with_suggested_action(self, suggested_action: impl Into<String>) -> Self
pub fn to_llm_payload(&self) -> ToolErrorResponse
Sourcepub fn to_llm_payload_enriched(
&self,
required_fields: Option<Vec<String>>,
usage_hint: Option<String>,
) -> ToolErrorResponse
pub fn to_llm_payload_enriched( &self, required_fields: Option<Vec<String>>, usage_hint: Option<String>, ) -> ToolErrorResponse
Build an enriched LLM payload with schema-derived corrective hints.
WHY: When the LLM sends invalid arguments, a bare “missing field X”
message forces it to guess the full schema from memory. By echoing
the required fields and a usage hint, we give it a precise checklist.
Hermes-agent’s coerce_tool_args + schema echo pattern reduced
retry loops by ~40% in their production telemetry.
Sourcepub fn to_llm_response(&self) -> String
pub fn to_llm_response(&self) -> String
Convert to a JSON string suitable for the LLM to parse.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether the LLM should retry with different parameters.
pub fn should_suppress_retry(&self) -> bool
pub fn category(&self) -> &'static str
pub fn code(&self) -> &str
Sourcepub fn code_num(&self) -> u16
pub fn code_num(&self) -> u16
Numeric error code for fast loop branching.
Maps each variant to a stable integer that survives refactors to the
string code. The conversation loop can branch on code_num instead of
code.as_str() comparisons for better performance and clarity.
pub fn tool_name(&self) -> Option<&str>
pub fn suggested_tool(&self) -> Option<&str>
pub fn suppression_key(&self) -> Option<String>
pub fn suggested_action(&self) -> Option<&str>
Trait Implementations§
Source§impl Error for ToolError
impl Error for ToolError
1.30.0 · 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()
Auto Trait Implementations§
impl Freeze for ToolError
impl RefUnwindSafe for ToolError
impl Send for ToolError
impl Sync for ToolError
impl Unpin for ToolError
impl UnsafeUnpin for ToolError
impl UnwindSafe for ToolError
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
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt 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.