pub struct ToolRegistry { /* private fields */ }Expand description
A registry of available tools
The registry stores tools and provides lookup by name.
Tools are stored as Arc<dyn Tool> to allow sharing.
§Thread Safety
The registry uses Arc for thread-safe sharing of tools.
Multiple async tasks can look up and execute tools concurrently.
§Example
let mut registry = ToolRegistry::new();
registry.register(Arc::new(MyTool));
if let Some(tool) = registry.get("my_tool") {
let output = tool.execute(params).await;
}Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register(&mut self, tool: Arc<dyn Tool>)
pub fn register(&mut self, tool: Arc<dyn Tool>)
Register a tool
If a tool with the same name already exists, it will be replaced.
Sourcepub fn get(&self, name: &str) -> Option<Arc<dyn Tool>>
pub fn get(&self, name: &str) -> Option<Arc<dyn Tool>>
Get a tool by name
Returns None if no tool with that name is registered.
Sourcepub fn tool_infos(&self) -> Vec<ToolInfo>
pub fn tool_infos(&self) -> Vec<ToolInfo>
Get info for all registered tools
Returns a vector of ToolInfo suitable for sending to an LLM.
Sourcepub fn tool_infos_with_store(&self, store: &PromptStore) -> Vec<ToolInfo>
pub fn tool_infos_with_store(&self, store: &PromptStore) -> Vec<ToolInfo>
Get info for all registered tools with descriptions from PromptStore
This allows tool descriptions to be overridden via the prompt configuration. If a tool has an override in the PromptStore, that description is used; otherwise, falls back to the tool’s built-in description.