(
&self,
gate_decision: ToolGateDecision,
tool_call: &ToolCall,
event_tx: &Option<mpsc::Sender<AgentEvent>>,
)
| 38 | } |
| 39 | |
| 40 | pub(super) async fn resolve_tool_gate_decision( |
| 41 | &self, |
| 42 | gate_decision: ToolGateDecision, |
| 43 | tool_call: &ToolCall, |
| 44 | event_tx: &Option<mpsc::Sender<AgentEvent>>, |
| 45 | ) -> NormalizedToolResult { |
| 46 | match gate_decision { |
| 47 | ToolGateDecision::Deny { |
| 48 | output, |
| 49 | event_reason, |
| 50 | reason, |
| 51 | } => { |
| 52 | tracing::info!( |
| 53 | tool_name = tool_call.name.as_str(), |
| 54 | gate_reason = reason.as_str(), |
| 55 | "Tool denied by safety gate" |
| 56 | ); |
| 57 | if let Some(tx) = event_tx { |
| 58 | tx.send(AgentEvent::PermissionDenied { |
| 59 | tool_id: tool_call.id.clone(), |
| 60 | tool_name: tool_call.name.clone(), |
| 61 | args: tool_call.args.clone(), |
| 62 | reason: event_reason, |
| 63 | }) |
| 64 | .await |
| 65 | .ok(); |
| 66 | } |
| 67 | NormalizedToolResult::denied(output) |
| 68 | } |
| 69 | ToolGateDecision::Execute { reason } => { |
| 70 | tracing::info!( |
| 71 | tool_name = tool_call.name.as_str(), |
| 72 | gate_reason = reason.as_str(), |
| 73 | "Tool approved by safety gate" |
| 74 | ); |
| 75 | self.execute_approved_tool_call( |
| 76 | event_tx, |
| 77 | &tool_call.id, |
| 78 | &tool_call.name, |
| 79 | &tool_call.args, |
| 80 | ) |
| 81 | .await |
| 82 | } |
| 83 | ToolGateDecision::Confirm { |
| 84 | timeout_ms, |
| 85 | timeout_action, |
| 86 | } => { |
| 87 | tracing::info!( |
| 88 | tool_name = tool_call.name.as_str(), |
| 89 | permission = "ask", |
| 90 | "Tool requires HITL confirmation" |
| 91 | ); |
| 92 | let confirmation = if let Some(cm) = self.config.confirmation_manager.as_ref() { |
| 93 | ToolConfirmationRuntime::new(cm.as_ref(), event_tx.as_ref()) |
| 94 | .resolve(ToolConfirmationRequest { |
| 95 | tool_id: &tool_call.id, |
| 96 | tool_name: &tool_call.name, |
| 97 | args: &tool_call.args, |
no test coverage detected