pub struct ToolRuntime { /* private fields */ }Expand description
Runtime layer that orchestrates tool execution with policy enforcement.
Implementations§
Source§impl ToolRuntime
impl ToolRuntime
Sourcepub fn new(registry: ToolRegistry, policy: RuntimePolicy) -> Self
pub fn new(registry: ToolRegistry, policy: RuntimePolicy) -> Self
Creates a new tool runtime wrapping the given registry.
Sourcepub fn registry(&self) -> &Arc<ScopedToolRegistry> ⓘ
pub fn registry(&self) -> &Arc<ScopedToolRegistry> ⓘ
Returns a reference to the underlying scoped tool registry.
Sourcepub fn registry_mut(&mut self) -> &mut Arc<ScopedToolRegistry> ⓘ
pub fn registry_mut(&mut self) -> &mut Arc<ScopedToolRegistry> ⓘ
Returns a mutable reference to the underlying scoped tool registry.
Sourcepub fn policy(&self) -> &RuntimePolicy
pub fn policy(&self) -> &RuntimePolicy
Returns the runtime policy.
Sourcepub fn register_tool(&self, tool: Arc<dyn Tool>) -> Option<Arc<dyn Tool>>
pub fn register_tool(&self, tool: Arc<dyn Tool>) -> Option<Arc<dyn Tool>>
Registers a tool at the base level of the scoped registry.
Returns the previously registered tool with the same name, if any.
Sourcepub fn unregister_tool(&self, name: &str) -> Option<Arc<dyn Tool>>
pub fn unregister_tool(&self, name: &str) -> Option<Arc<dyn Tool>>
Unregisters a tool from the base level of the scoped registry.
Returns the removed tool if it existed, or None if no tool with
name was registered.
Sourcepub async fn execute_batch(
&self,
calls: Vec<ToolCall>,
session_id: Uuid,
message_id: Uuid,
execution_store: Option<&dyn ExecutionStore>,
) -> RuntimeResult<Vec<ToolExecutionOutcome>>
pub async fn execute_batch( &self, calls: Vec<ToolCall>, session_id: Uuid, message_id: Uuid, execution_store: Option<&dyn ExecutionStore>, ) -> RuntimeResult<Vec<ToolExecutionOutcome>>
Executes a batch of tool calls with bounded parallelism, timeout, validation, and optional execution recording.
Tool calls are partitioned by Tool::is_concurrency_safe:
concurrent-safe tools execute in parallel (bounded by semaphore),
while exclusive tools execute sequentially, one at a time.
Results are merged in the original call order.
Each tool call is executed independently. If execution_store is
provided, each execution is recorded.
When continue_on_tool_failure is true (from policy), failed tool
calls produce error messages but do not abort the batch.
§Errors
Returns RuntimeError::ToolTimeout when the semaphore is exhausted,
or propagates errors from individual tool executions when the policy
does not allow continuation on failure.