openai_agents_rust/tools/
traits.rs1use crate::agent::traits::AgentContext;
2use crate::error::AgentError;
3use async_trait::async_trait;
4use serde_json::Value;
5
6#[async_trait]
8pub trait Tool: Send + Sync {
9 fn name(&self) -> &str;
10 fn description(&self) -> &str {
11 ""
12 }
13 fn openai_tool_spec(&self) -> Option<Value> {
16 None
17 }
18 async fn is_enabled(&self, _ctx: &AgentContext) -> bool {
20 true
21 }
22 async fn call(&self, input: &str) -> Result<String, AgentError>;
24
25 async fn call_with_context(
27 &self,
28 ctx: &AgentContext,
29 _tool_call_id: Option<&str>,
30 input: &str,
31 ) -> Result<String, AgentError> {
32 let _ = ctx; self.call(input).await
34 }
35}