Skip to main content

Module tool

Module tool 

Source
Expand description

Tool authoring contracts, dispatch context, and canonical execution values. PortableTool provides context-free calls; Tool adds ToolContext. Both can be adapted into ErasedTool handlers.

use rig_core::tool::ToolOutput;

let output = ToolOutput::json(serde_json::json!({"count": 3}));
assert!(output.as_json().is_some());

Re-exports§

pub use context::ContextValue;
pub use context::PublishedContext;
pub use context::ToolContext;
pub use context::ToolContextError;
pub use context::ToolResultContext;
pub use contextual::DynamicTool;
pub use contextual::ErasedTool;
pub use contextual::LivenessFn;
pub use contextual::Tool;
pub use contextual::ToolEmbedding;
pub use contextual::tool_definition;
pub use managed::ManagedToolSink;
pub use managed::ManagedToolToken;
pub use portable::PortableTool;
pub use portable::PortableToolEmbedding;

Modules§

builtin
Built-in tools shipped with rig that agents can use out of the box.
context
Typed inbound context and explicitly published host-only tool-result metadata.
contextual
Contextual tool authoring and JSON-argument dispatch adapters. ToolContext carries typed inbound values and host-only result metadata; model-visible outputs retain their text, JSON, or multimodal representation.
managed
Registry contracts for refreshable external tool sources. Generation tokens protect newer registrations from stale refreshes, while DynamicTool::is_live reports disconnection without tool execution.
portable
Context-free tool authoring contracts.

Structs§

ToolExecutionError
One public envelope for every tool execution failure.
ToolOutput
The canonical model-visible output produced by a tool.
ToolResult
The single structured execution view used by dispatch, hooks, and telemetry.

Enums§

ToolErrorKind
Normalized classification for a tool execution error.

Traits§

IntoToolOutput
Conversion into Rig’s canonical tool output.