pub struct ToolRegistry { /* private fields */ }Expand description
Registry of available tools for the agent loop.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn with_cache(self, cache: Arc<dyn ToolCache>) -> Self
pub fn with_cache(self, cache: Arc<dyn ToolCache>) -> Self
Attach a tool result cache.
Sourcepub fn register(&mut self, spec: ToolSpec)
pub fn register(&mut self, spec: ToolSpec)
Register a tool. Overwrites any existing tool with the same name.
Sourcepub fn register_tools(&mut self, specs: impl IntoIterator<Item = ToolSpec>)
pub fn register_tools(&mut self, specs: impl IntoIterator<Item = ToolSpec>)
Register multiple tools at once.
Equivalent to calling register for each spec in order. Duplicate
names overwrite earlier entries.
Sourcepub fn with_tool(self, spec: ToolSpec) -> Self
pub fn with_tool(self, spec: ToolSpec) -> Self
Fluent builder: register a tool and return self.
Allows chaining multiple registrations:
use llm_agent_runtime::agent::{ToolRegistry, ToolSpec};
let registry = ToolRegistry::new()
.with_tool(ToolSpec::new("search", "Search", |args| args.clone()))
.with_tool(ToolSpec::new("calc", "Calculate", |args| args.clone()));Sourcepub async fn call(
&self,
name: &str,
args: Value,
) -> Result<Value, AgentRuntimeError>
pub async fn call( &self, name: &str, args: Value, ) -> Result<Value, AgentRuntimeError>
Call a tool by name.
§Errors
AgentRuntimeError::AgentLoop— tool not found, required field missing, or custom validator rejected the argumentsAgentRuntimeError::CircuitOpen— the tool’s circuit breaker is open (only possible when theorchestratorfeature is enabled)
Sourcepub fn tool_names(&self) -> Vec<&str>
pub fn tool_names(&self) -> Vec<&str>
Return the list of registered tool names.
Trait Implementations§
Source§impl Debug for ToolRegistry
impl Debug for ToolRegistry
Auto Trait Implementations§
impl Freeze for ToolRegistry
impl !RefUnwindSafe for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl UnsafeUnpin for ToolRegistry
impl !UnwindSafe for ToolRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more