pub trait AgentTool<TCtx>: Send + Sync {
// Required methods
fn name(&self) -> String;
fn description(&self) -> String;
fn parameters(&self) -> JSONSchema;
fn execute<'a>(
&'a self,
args: Value,
context: &'a TCtx,
state: &'a RunState,
) -> BoxFuture<'a, Result<AgentToolResult, Box<dyn Error + Send + Sync>>>;
}Expand description
Agent tool that can be used by the agent to perform specific tasks. Any
type that implements the AgentTool trait can be used as a tool.
Required Methods§
Sourcefn description(&self) -> String
fn description(&self) -> String
A description of the tool to instruct the model how and when to use it.
Sourcefn parameters(&self) -> JSONSchema
fn parameters(&self) -> JSONSchema
The JSON schema of the parameters that the tool accepts. The type must be “object”.
Sourcefn execute<'a>(
&'a self,
args: Value,
context: &'a TCtx,
state: &'a RunState,
) -> BoxFuture<'a, Result<AgentToolResult, Box<dyn Error + Send + Sync>>>
fn execute<'a>( &'a self, args: Value, context: &'a TCtx, state: &'a RunState, ) -> BoxFuture<'a, Result<AgentToolResult, Box<dyn Error + Send + Sync>>>
The function that will be called to execute the tool with given parameters and context.
If the tool throws an error, the agent will be interrupted and the error
will be propagated. To avoid interrupting the agent, the tool must
return an AgentToolResult with is_error set to true.