agent_base/tool/
policy.rs1use async_trait::async_trait;
2use serde_json::Value;
3
4use crate::types::{AgentResult, ApprovalRequest};
5use super::{ToolContext, ToolOutput};
6
7#[async_trait]
8pub trait ToolPolicy: Send + Sync {
9 async fn evaluate_approval(
10 &self,
11 tool_name: &str,
12 args: &Value,
13 ) -> Option<ApprovalRequest>;
14
15 fn before_call(&self, tool_name: &str, args: &Value, ctx: &ToolContext) -> AgentResult<()> {
16 let _ = (tool_name, args, ctx);
17 Ok(())
18 }
19
20 fn after_call(&self, tool_name: &str, args: &Value, result: &ToolOutput, ctx: &ToolContext) -> AgentResult<()> {
21 let _ = (tool_name, args, result, ctx);
22 Ok(())
23 }
24}