Skip to main content

potato_type/tools/
async_tool.rs

1use crate::TypeError;
2use async_trait::async_trait;
3use serde_json::Value;
4use std::fmt::Debug;
5
6/// Async version of the Tool trait for use in the agentic loop.
7/// Implements async execute for non-blocking tool execution.
8#[async_trait]
9pub trait AsyncTool: Send + Sync + Debug {
10    fn name(&self) -> &str;
11    fn description(&self) -> &str;
12    fn parameter_schema(&self) -> Value;
13    async fn execute(&self, args: Value) -> Result<Value, TypeError>;
14
15    /// Optional downcast hook. Override in concrete types that need session-aware dispatch.
16    fn as_any(&self) -> Option<&dyn std::any::Any> {
17        None
18    }
19}