Documentation
¶
Overview ¶
Package toolerrors provides structured error types for tool invocation failures. ToolError preserves error chains and supports errors.Is/As while maintaining serialization compatibility for agent-as-tool scenarios.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kind ¶ added in v2.1.0
type Kind string
Kind classifies a tool error for runtime policy and durable workflow records.
const ( // KindOutcomeUnknown means execution may have caused an effect, but its // terminal result could not be confirmed. KindOutcomeUnknown Kind = "outcome_unknown" )
type ToolError ¶
type ToolError struct {
// Message is the human-readable summary of the failure.
Message string
// Kind is a stable machine-readable classification for runtime policy.
Kind Kind `json:"kind,omitempty"`
// Cause links to the underlying tool error, enabling error chains with errors.Is/As.
Cause *ToolError
}
ToolError represents a structured tool failure that preserves message and causal context while still implementing the standard error interface. Tool errors may be nested via Cause to retain rich diagnostics across retries and agent-as-tool hops.
func New ¶
New constructs a ToolError with the provided message. Use when the failure does not wrap an underlying error but still requires structured reporting.
func NewWithCause ¶
NewWithCause constructs a ToolError that wraps an underlying error. The cause is converted into a ToolError chain so error metadata survives serialization while still supporting errors.Is/As through Unwrap.
func NewWithKind ¶ added in v2.1.0
NewWithKind constructs a ToolError with a stable machine-readable kind.