Skip to main content

opi_agent/
tool.rs

1//! Tool calling abstraction.
2
3use async_trait::async_trait;
4use serde_json::Value;
5
6#[async_trait]
7pub trait Tool: Send + Sync {
8    fn name(&self) -> &str;
9    fn description(&self) -> &str;
10    async fn execute(&self, input: Value) -> Result<Value, crate::Error>;
11}
12
13#[derive(Debug, thiserror::Error)]
14pub enum Error {
15    #[error("tool execution failed: {0}")]
16    ExecutionFailed(String),
17    #[error("invalid input: {0}")]
18    InvalidInput(String),
19}