pub enum ToolError {
InvalidInput {
tool: String,
source: Error,
},
Handler {
tool: String,
source: HandlerError,
},
MissingIdempotencyKey {
tool: String,
path: String,
detail: String,
},
MalformedResult {
tool: String,
detail: String,
},
OutputSerialization {
tool: String,
source: Error,
},
}Expand description
The error the type-erased dispatch layer
(DynTool::call_json) returns.
The variants are deliberately distinct so the runtime loop can route on them:
ToolError::InvalidInputmeans the JSON the model produced did not deserialize into the tool’sInputtype. The handler was not called. The loop feeds this back to the model to let it fix its arguments.ToolError::Handlermeans the handler ran and returned aHandlerError. This is a real execution failure, subject to the effect’s retry policy.ToolError::MalformedResultmeans the tool ran and returned something this layer could not read as a result. LikeOutputSerializationit is the tool author’s own bug, so it is not retryable: the same bytes decode the same way on a second attempt, and the only thing a retry buys is a slower answer to a question already settled.ToolError::OutputSerializationmeans the handler succeeded but itsOutputvalue could not be serialized to JSON. This is an internal fault in the tool definition, not the model’s doing and not a retryable failure.ToolError::MissingIdempotencyKeymeans the operator declared which input field identifies this tool’s calls and the call does not carry it. The tool was not called, and it will not be called unkeyed. LikeInvalidInputthis is the arguments being wrong, so the loop feeds it back to the model rather than retrying it.
Variants§
InvalidInput
The model’s JSON input did not match the tool’s input schema. The handler was never invoked.
Fields
Handler
The handler ran and returned a failure.
MissingIdempotencyKey
The tool has a declared idempotency key path and this call’s input does not yield a key from it. Nothing ran.
See IdempotencyPath::derive for what
counts as a key and why falling back to an unkeyed call is not an option
here.
Fields
MalformedResult
The tool ran and handed back a result the dispatch layer could not read.
Distinct from Handler, which is the tool saying its
own work failed. Here the work may well have succeeded; what arrived
with it is unreadable, which is a mistake in the tool rather than in
the world it talked to. That is the whole reason for the separate
variant: a handler failure is worth another attempt under the right
effect, and an unreadable result never is.
Fields
OutputSerialization
The handler succeeded but its output could not be serialized to JSON.
Trait Implementations§
Source§impl Error for ToolError
impl Error for ToolError
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()