pub struct AgentTool { /* private fields */ }Expand description
AgentTool - wraps a Callable as a Tool
⚠️ PRIVILEGED: This adapter may only be constructed by trusted runtime components. See module-level documentation for security implications.
This allows exposing agents, graphs, or other Callables as tools that can be
invoked by LLMs. The Callable’s run() method is invoked with the tool’s
JSON arguments serialized as a string.
Implementations§
Source§impl AgentTool
impl AgentTool
Sourcepub fn new(
callable: DynCallable,
name: impl Into<String>,
description: impl Into<String>,
parameters: Value,
) -> Self
pub fn new( callable: DynCallable, name: impl Into<String>, description: impl Into<String>, parameters: Value, ) -> Self
Create a new AgentTool
⚠️ SECURITY: This constructor is privileged. Only trusted runtime components
(kernel, runner) should create AgentTool instances.
§Arguments
callable- The callable to wrap (agent, graph, etc.)name- Tool name (for LLM tool schema)description- Tool description (for LLM tool schema)parameters- JSON schema for tool parameters (defaults to empty object)
§Example
ⓘ
// ✅ CORRECT: Created by trusted runtime
let agent = Arc::new(LlmCallable::new(...));
let tool = AgentTool::new(
agent,
"sub_agent",
"A sub-agent that handles specific tasks",
json!({
"type": "object",
"properties": {
"task": {"type": "string", "description": "Task description"}
},
"required": ["task"]
})
);Trait Implementations§
Source§impl Tool for AgentTool
impl Tool for AgentTool
Source§fn description(&self) -> &str
fn description(&self) -> &str
Tool description
Source§fn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
JSON schema for tool parameters
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the tool with the given arguments
Source§fn requires_network(&self) -> bool
fn requires_network(&self) -> bool
Whether this tool requires network access.
Default is
true (conservative).
Override to false for local-only tools (e.g., file, calculator).Auto Trait Implementations§
impl Freeze for AgentTool
impl !RefUnwindSafe for AgentTool
impl Send for AgentTool
impl Sync for AgentTool
impl Unpin for AgentTool
impl UnsafeUnpin for AgentTool
impl !UnwindSafe for AgentTool
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