pub struct AgentTools { /* private fields */ }Expand description
Tools registry used by the agent.
All tools are eager-loaded and included in every LLM request.
Implementations§
Source§impl AgentTools
impl AgentTools
Sourcepub fn register<T: Tool + 'static>(
&mut self,
tool: T,
) -> Result<(), RegisterError>
pub fn register<T: Tool + 'static>( &mut self, tool: T, ) -> Result<(), RegisterError>
Registers an eager (always-loaded) tool.
§Errors
Returns RegisterError if the name collides with a tool that is
already registered, or the tool has no description for the model to
read.
Sourcepub fn definitions(&self) -> Vec<ToolDefinition>
pub fn definitions(&self) -> Vec<ToolDefinition>
Returns definitions of all registered tools.
Sourcepub fn active_definitions(&self) -> Vec<ToolDefinition>
pub fn active_definitions(&self) -> Vec<ToolDefinition>
Returns all tool definitions (eager + MCP).
Sourcepub async fn call(
&self,
name: &str,
args: &str,
cx: ToolContext,
) -> Result<ToolResult>
pub async fn call( &self, name: &str, args: &str, cx: ToolContext, ) -> Result<ToolResult>
Calls a tool by name with JSON arguments.
Searches eager tools first, then MCP tools. An eager tool runs with
cx as its ToolContext; an MCP tool runs in its server, which
reports to nobody here because no progress token is sent with the
request.
§Errors
Returns an error if the tool is not found or execution fails.
Trait Implementations§
Source§impl Debug for AgentTools
impl Debug for AgentTools
Auto Trait Implementations§
impl !RefUnwindSafe for AgentTools
impl !UnwindSafe for AgentTools
impl Forget for AgentTools
impl Freeze for AgentTools
impl Move for AgentTools
impl Send for AgentTools
impl Sync for AgentTools
impl Unpin for AgentTools
impl UnsafeUnpin for AgentTools
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