mofa_foundation/llm/tool_executor.rs
1//! Tool executor trait shared across LLM client and agent loop.
2//!
3//! This trait unifies tool execution for both direct LLM calls and AgentLoop
4//! processing, and supports async discovery of available tools.
5
6use super::types::{LLMResult, Tool};
7
8/// Tool executor trait for LLM tool calling.
9#[async_trait::async_trait]
10pub trait ToolExecutor: Send + Sync {
11 /// Execute a tool call by name with JSON arguments.
12 async fn execute(&self, name: &str, arguments: &str) -> LLMResult<String>;
13
14 /// Get available tool definitions.
15 ///
16 /// Default returns an empty list for executors that don't expose tools.
17 async fn available_tools(&self) -> LLMResult<Vec<Tool>> {
18 Ok(Vec::new())
19 }
20}