pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn call<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn description(&self) -> &str { ... }
fn openai_tool_spec(&self) -> Option<Value> { ... }
fn is_enabled<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentContext,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn call_with_context<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 AgentContext,
_tool_call_id: Option<&'life2 str>,
input: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
}
Expand description
Basic tool trait comparable to Python FunctionTool.
Required Methods§
Provided Methods§
fn description(&self) -> &str
Sourcefn openai_tool_spec(&self) -> Option<Value>
fn openai_tool_spec(&self) -> Option<Value>
Optional OpenAI Chat Completions tool spec for this tool. Return None if the tool shouldn’t be exposed to the model.
Sourcefn is_enabled<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentContext,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn is_enabled<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentContext,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Whether the tool is enabled in the current context.
Sourcefn call_with_context<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 AgentContext,
_tool_call_id: Option<&'life2 str>,
input: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn call_with_context<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 AgentContext,
_tool_call_id: Option<&'life2 str>,
input: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Optional context-aware call. Default delegates to call
.