pub struct DynamicTool { /* private fields */ }Expand description
A dynamically-constructed tool from a definition and execution function.
This is useful for wrapping external tool definitions (e.g., from extensions
or plugins) into the AgentTool interface without requiring a dedicated struct.
Implementations§
Source§impl DynamicTool
impl DynamicTool
Sourcepub fn new(
name: impl Into<String>,
label: impl Into<String>,
description: impl Into<String>,
parameters: Value,
execute_fn: impl Fn(&str, Value, Option<Receiver<()>>) -> Pin<Box<dyn Future<Output = Result<AgentToolResult, ToolError>> + Send>> + Send + Sync + 'static,
) -> Self
pub fn new( name: impl Into<String>, label: impl Into<String>, description: impl Into<String>, parameters: Value, execute_fn: impl Fn(&str, Value, Option<Receiver<()>>) -> Pin<Box<dyn Future<Output = Result<AgentToolResult, ToolError>> + Send>> + Send + Sync + 'static, ) -> Self
Create a new dynamic tool from components.
Trait Implementations§
Source§impl AgentTool for DynamicTool
impl AgentTool for DynamicTool
Source§fn description(&self) -> &str
fn description(&self) -> &str
Description for the model
Source§fn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
JSON Schema for parameters
Source§fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_call_id: &'life1 str,
params: Value,
signal: Option<Receiver<()>>,
_ctx: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<AgentToolResult, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_call_id: &'life1 str,
params: Value,
signal: Option<Receiver<()>>,
_ctx: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<AgentToolResult, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute the tool with the given tool call ID and parameters. Read more
Source§fn essential(&self) -> bool
fn essential(&self) -> bool
Whether this tool is essential (cannot be disabled).
Essential tools: read, write, edit, bash, grep, find, ls
Optional tools: web_search, github, subagent, etc.
Source§fn on_progress(&self, _callback: ProgressCallback)
fn on_progress(&self, _callback: ProgressCallback)
Called with progress updates during execution.
Tools can override this to emit streaming updates.
Source§fn to_definition(&self) -> ToolDefinition
fn to_definition(&self) -> ToolDefinition
Convert to ToolDefinition
Auto Trait Implementations§
impl Freeze for DynamicTool
impl !RefUnwindSafe for DynamicTool
impl Send for DynamicTool
impl Sync for DynamicTool
impl Unpin for DynamicTool
impl UnsafeUnpin for DynamicTool
impl !UnwindSafe for DynamicTool
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