pub struct ToolServerHandle(/* private fields */);Expand description
A cheaply-cloneable handle to the shared tool server state.
All operations acquire locks directly on the underlying state. Multiple handles (e.g. across agents) can share the same state without channel-based message routing.
Implementations§
Source§impl ToolServerHandle
impl ToolServerHandle
Sourcepub async fn add_tool<T>(&self, tool: T)where
T: Tool + 'static,
pub async fn add_tool<T>(&self, tool: T)where
T: Tool + 'static,
Register a new static tool. Re-registering an existing name replaces the implementation (last wins) and keeps its position.
Sourcepub async fn add_dynamic_tool(&self, tool: DynamicTool)
pub async fn add_dynamic_tool(&self, tool: DynamicTool)
Register a runtime-defined static tool.
Sourcepub async fn add_portable_dynamic_tool(&self, tool: PortableDynamicTool)
pub async fn add_portable_dynamic_tool(&self, tool: PortableDynamicTool)
Register a context-free dynamic tool through the classic adapter.
Sourcepub async fn append_toolset(&self, toolset: ToolSet)
pub async fn append_toolset(&self, toolset: ToolSet)
Merge an entire toolset into the server in registration order. Existing names are replaced (last wins) and keep their position.
Sourcepub async fn remove_tool(&self, tool_name: &str)
pub async fn remove_tool(&self, tool_name: &str)
Remove a tool by name.
Sourcepub async fn execute(
&self,
tool_name: &str,
args: &str,
context: &mut ToolContext,
) -> ToolResult
pub async fn execute( &self, tool_name: &str, args: &str, context: &mut ToolContext, ) -> ToolResult
Look up and execute a tool through the canonical structured path.
The implementation handle is cloned under a brief read lock, so a long
execution never blocks registration changes. The tool receives one
snapshot of the supplied inbound values. Its result metadata is
published back to context, while mutations to its inbound snapshot are
discarded.
Sourcepub async fn get_tool_defs(
&self,
prompt: Option<String>,
) -> Result<Vec<ToolDefinition>, ToolServerError>
pub async fn get_tool_defs( &self, prompt: Option<String>, ) -> Result<Vec<ToolDefinition>, ToolServerError>
Retrieve tool definitions, optionally using a prompt to select dynamic tools from configured vector stores.
Trait Implementations§
Source§impl Clone for ToolServerHandle
impl Clone for ToolServerHandle
Source§fn clone(&self) -> ToolServerHandle
fn clone(&self) -> ToolServerHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more