Skip to main content

agent_base/tool/
policy.rs

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