locode_tools/error.rs
1//! The tool error taxonomy (ADR-0004).
2
3use thiserror::Error;
4
5/// How a tool call failed, split into exactly two recovery paths (ADR-0004).
6///
7/// **Default everything to [`ToolError::Respond`].** Bad arguments, an unknown
8/// tool, a not-found path, a failed command, a timeout — all are *soft*: they
9/// become a `tool_result { is_error: true }` the model reads and retries from.
10/// [`ToolError::Fatal`] is reserved for the rare case where the transcript itself
11/// is unrecoverable; it aborts the turn with a non-zero exit.
12#[derive(Debug, Error)]
13pub enum ToolError {
14 /// Soft error: surfaced to the model as an `is_error` tool result so it can
15 /// self-correct. The loop keeps iterating.
16 #[error("{0}")]
17 Respond(String),
18 /// Hard error: the transcript is unrecoverable; abort the turn.
19 #[error("{0}")]
20 Fatal(String),
21}