pub struct ToolExecutor { /* private fields */ }Expand description
Tool registry and executor with optional result caching.
Implementations§
Source§impl ToolExecutor
impl ToolExecutor
Sourcepub fn builder() -> ExecutorBuilder
pub fn builder() -> ExecutorBuilder
Create an executor builder for fluent API
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear the cache
Sourcepub fn invalidate_cache_for_tool(&self, tool_name: &str)
pub fn invalidate_cache_for_tool(&self, tool_name: &str)
Invalidate cache for a specific tool
Sourcepub fn cache_stats(&self) -> CacheStats
pub fn cache_stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn add_dyn_tool(&self, tool: Box<dyn DynTool>) -> ToolResult<&Self>
pub fn add_dyn_tool(&self, tool: Box<dyn DynTool>) -> ToolResult<&Self>
Chain-friendly: add a dynamic tool, returns error if already registered
Sourcepub fn unregister(&self, name: &str) -> ToolResult<()>
pub fn unregister(&self, name: &str) -> ToolResult<()>
Unregister a tool
Sourcepub fn input_schema(&self, name: &str) -> Option<Value>
pub fn input_schema(&self, name: &str) -> Option<Value>
Get input schema for a tool
Sourcepub fn tool_names(&self) -> Vec<String>
pub fn tool_names(&self) -> Vec<String>
List tool names in deterministic lexicographic order.
Sourcepub async fn execute(
&self,
tool_name: &str,
input: Value,
) -> ToolResult<ExecutionResult>
pub async fn execute( &self, tool_name: &str, input: Value, ) -> ToolResult<ExecutionResult>
Execute a tool with caching, timeout, and exponential backoff.
Tool-level failures are returned as Ok(ExecutionResult) with its
success field set to false. Use ToolExecutor::execute_simple
when failures should be returned as ToolError values instead.
Sourcepub async fn execute_simple(
&self,
tool_name: &str,
input: Value,
) -> ToolResult<Value>
pub async fn execute_simple( &self, tool_name: &str, input: Value, ) -> ToolResult<Value>
Execute a tool and return its JSON value, converting an unsuccessful
execution into a ToolError.
Sourcepub fn add_functions_from_dir_with_registry(
&self,
dir: impl AsRef<Path>,
handlers: &HashMap<String, ToolHandler>,
strict: bool,
) -> ToolResult<Vec<String>>
pub fn add_functions_from_dir_with_registry( &self, dir: impl AsRef<Path>, handlers: &HashMap<String, ToolHandler>, strict: bool, ) -> ToolResult<Vec<String>>
Register function specifications loaded from .json files in dir.
Each file may contain a direct function object or an OpenAI-style
{ "type": "function", "function": ... } wrapper. handlers maps
function names to implementations. When strict is false, files
without a matching handler are skipped; otherwise they cause an error.
Returns the list of function names successfully registered.
Sourcepub async fn execute_tool_calls_parallel(
&self,
calls: &[ToolCallMessage],
) -> Vec<TextMessage>
pub async fn execute_tool_calls_parallel( &self, calls: &[ToolCallMessage], ) -> Vec<TextMessage>
Execute tool calls concurrently, returning one tool message per call.
Results are returned in completion order; use
Self::execute_tool_calls_ordered to restore input order.
Sourcepub async fn execute_tool_calls_ordered(
&self,
calls: &[ToolCallMessage],
) -> Vec<TextMessage>
pub async fn execute_tool_calls_ordered( &self, calls: &[ToolCallMessage], ) -> Vec<TextMessage>
Execute tool calls concurrently and restore input order in the result.
At most eight handlers run concurrently. Invalid arguments, execution errors, and handler panics are isolated to their call and encoded as a tool-error message, so one failure does not discard other results.
Sourcepub fn export_tool_as_function(&self, name: &str) -> Option<Tools>
pub fn export_tool_as_function(&self, name: &str) -> Option<Tools>
Export one registered tool as an LLM function definition.
Sourcepub fn export_all_tools_as_functions(&self) -> Vec<Tools>
pub fn export_all_tools_as_functions(&self) -> Vec<Tools>
Export all registered tools as function definitions sorted by name.
Sourcepub fn export_tools_filtered<F>(&self, filter: F) -> Vec<Tools>
pub fn export_tools_filtered<F>(&self, filter: F) -> Vec<Tools>
Export enabled tools selected by a metadata predicate.
Sourcepub fn config(&self) -> &ExecutionConfig
pub fn config(&self) -> &ExecutionConfig
Get the executor’s ExecutionConfig.
Trait Implementations§
Source§impl Clone for ToolExecutor
impl Clone for ToolExecutor
Source§fn clone(&self) -> ToolExecutor
fn clone(&self) -> ToolExecutor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more