Skip to main content

Module contextual

Module contextual 

Source
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§

DynamicTool
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.
ToolEmbedding
A tool that can be stored in a vector store and reconstructed for RAG.

Functions§

tool_definition
A tool’s ToolDefinition from a typed tool, with its annotations.
tool_name
A typed tool’s Tool::NAME as a ToolName.

Type Aliases§

LivenessFnNon-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.