Skip to main content

Module tool

Module tool 

Source
Expand description

Module defining tool related structs and traits.

The Tool trait defines a simple interface for creating tools that can be used by Agents.

The ToolEmbedding trait extends the Tool trait to allow for tools that can be stored in a vector store and RAGged.

The ToolSet struct is a collection of tools that can be used by an Agent and optionally RAGged.

§Structured tool results

A tool call resolves to a structured ToolExecutionResult — model-visible output, a machine-readable ToolOutcome (success, a classified ToolFailure, skipped, or denied), and ToolResultExtensions metadata that is never sent to the model. This is what flows to the StepEvent::ToolResult hook so a policy can steer on why a tool failed without parsing strings. A tool classifies its own error type via Tool::classify_error and can return richer outcomes/metadata via Tool::call_structured and ToolReturn.

Modules§

builtin
Built-in tools shipped with rig that agents can use out of the box.
rmcprmcp
MCP (Model Context Protocol) integration via the rmcp crate.
server

Structs§

MissingExtension
Error returned by ToolCallExtensions::require and ToolResultExtensions::require when the requested value is not present.
ToolCallExtensions
Per-call runtime extensions supplied to a tool by its caller.
ToolExecutionResult
The full structured result of a single tool execution.
ToolFailure
A structured, model-independent description of a tool execution failure.
ToolResultExtensions
Type-erased metadata a tool attaches to its structured result.
ToolReturn
A tool’s return value carrying an optional structured outcome and metadata.
ToolSet
A struct that holds a set of tools.
ToolSetBuilder
Builder for constructing a ToolSet with static and dynamic tools.

Enums§

ToolError
ToolFailureKind
How a tool execution failed, as a closed set of standard kinds.
ToolOutcome
The structured outcome of a tool call: what happened, independent of the model-visible text.
ToolReturnOutcome
The outcome a tool declares for a call it executed.
ToolSetError

Traits§

Tool
Trait that represents a simple LLM tool.
ToolDyn
Wrapper trait to allow for dynamic dispatch of simple tools.
ToolEmbedding
Trait that represents an LLM tool that can be stored in a vector store and RAGged
ToolEmbeddingDyn
Wrapper trait to allow for dynamic dispatch of raggable tools

Functions§

tool_definition
Generate a provider-facing ToolDefinition from a registered tool’s flat metadata.