Expand description
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.
use rig_core::{message::ToolName, tool::{DynamicTool, ToolOutput}};
let tool = DynamicTool::new_with_context(ToolName::new("echo")?, "Echo JSON", serde_json::json!({}),
|_context, args| Box::pin(async move { Ok(ToolOutput::json(args)) }));
assert_eq!(tool.name(), "echo");Structs§
- Dynamic
Tool - A tool defined at runtime: its definition and a callback over JSON
arguments. It is its own handler (
Serve), keyed by its name. The optional liveness probe supports registry retirement; serving does not consult it.
Traits§
- Tool
- A typed LLM tool.
- Tool
Embedding - A tool that can be stored in a vector store and reconstructed for RAG.
Functions§
- tool_
definition - A tool’s
ToolDefinitionfrom a typed tool, with its annotations. - tool_
name - A typed tool’s
Tool::NAMEas aToolName.
Type Aliases§
- Liveness
Fn Non- target_family=wasm - Reports whether a tool’s owner still serves it. Registries check lazily on
reads or reconciliation; calls before retirement may fail with a transport
error rather than
HandlerUnavailable.