Skip to main content

tiny_loop/tool/
executor.rs

1mod parallel;
2mod sequential;
3
4use super::Tool;
5use crate::types::{Message, ToolCall};
6use async_trait::async_trait;
7
8pub use parallel::*;
9pub use sequential::*;
10
11/// Executes tool calls with different strategies (parallel, sequential, etc.)
12#[async_trait]
13pub trait ToolExecutor {
14    /// Adds a tool to the executor. Returns the previous tool with the same name if it exists.
15    fn add(&mut self, name: String, tool: Box<dyn Tool + Sync>) -> Option<Box<dyn Tool + Sync>>;
16
17    /// Executes the given tool calls and returns the results as messages.
18    async fn execute(&self, calls: Vec<ToolCall>) -> Vec<Message>;
19}