pub enum ToolCallExtractError {
NoCallFound {
tried: Vec<ExtractionStrategy>,
},
MalformedArguments {
name: String,
source: Error,
},
UnknownTool {
name: String,
},
SchemaInvalid {
name: String,
violations: Vec<SchemaViolation>,
},
Retry(InferenceError),
Unrepairable {
attempts: u32,
last_error: Box<ToolCallExtractError>,
},
}Expand description
Failure modes of tool-call extraction and validation.
Why: Distinguishes “no candidate call found at all” from “found a call but
its arguments are broken” from “found valid JSON but it fails the tool’s
schema” — each warrants a different corrective message from
repair::build_corrective_message. Unrepairable is the terminal variant
the bounded repair loop returns once max_attempts is exhausted.
Test: Constructed and matched throughout mod.rs, repair.rs tests.
Variants§
NoCallFound
No strategy in the configured order recovered a tool call.
Why: The model may have answered in plain prose with no embedded call at all, or used a convention none of the four strategies recognise. What: Carries the strategies that were attempted, in order, for diagnostics and for the corrective message.
Fields
tried: Vec<ExtractionStrategy>Strategies attempted, in the order they were tried.
MalformedArguments
A candidate call’s argument text failed to parse as JSON.
Why: The native wire format carries arguments as a JSON-encoded
string (see llm::FunctionCall::arguments); a model can emit
syntactically broken JSON there even when the surrounding envelope is
well-formed.
What: Carries the tool name (best-effort — the name itself parses
independently of the arguments) and the underlying serde_json error.
Fields
UnknownTool
The extracted call names a tool with no registered schema.
Why: Validation needs a schema to check against; a hallucinated tool
name has none. This is distinct from SchemaInvalid because there is
nothing to validate the arguments AGAINST, not merely a mismatch.
What: Carries the unrecognised tool name.
SchemaInvalid
The extracted call’s arguments failed schema validation.
Why: The most common repairable failure — the model called a real
tool but got the argument shape wrong (missing required field, wrong
type, disallowed extra key).
What: Carries the tool name and every SchemaViolation found (not
just the first) so a single corrective message can address them all.
Fields
violations: Vec<SchemaViolation>All violations found; see schema::validate_args.
Retry(InferenceError)
The retry callback’s chat call failed (transport/API error).
Why: repair::extract_with_repair’s retry closure typically wraps a
real InferenceAdapter::chat call; that call can fail independently of
extraction. Wrapping it here lets the repair loop propagate it with
? instead of requiring every caller to define its own error type.
What: Wraps the underlying InferenceError.
Unrepairable
The bounded repair loop exhausted its attempts without success.
Why: The terminal, structured (never-panicking) error the repair loop
returns once max_attempts corrective round-trips have all failed —
this is the “Unrepairable → structured error” acceptance criterion.
What: Carries how many attempts were made and the last failure seen.
Fields
attempts: u32Number of repair attempts made (corrective round-trips), not counting the initial extraction attempt.
last_error: Box<ToolCallExtractError>The failure from the final attempt.
Trait Implementations§
Source§impl Debug for ToolCallExtractError
impl Debug for ToolCallExtractError
Source§impl Display for ToolCallExtractError
impl Display for ToolCallExtractError
Source§impl Error for ToolCallExtractError
impl Error for ToolCallExtractError
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<InferenceError> for ToolCallExtractError
impl From<InferenceError> for ToolCallExtractError
Source§fn from(source: InferenceError) -> Self
fn from(source: InferenceError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for ToolCallExtractError
impl !UnwindSafe for ToolCallExtractError
impl Freeze for ToolCallExtractError
impl Send for ToolCallExtractError
impl Sync for ToolCallExtractError
impl Unpin for ToolCallExtractError
impl UnsafeUnpin for ToolCallExtractError
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> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more