From 27777d4b8f8b59e58de35688eb1ce4ce66061053 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 28 Aug 2025 14:18:25 -0400 Subject: [PATCH] Have ACP respect always_allow_tool_actions (#37104) Release Notes: - ACP agents now respect the always_allow_tool_actions setting --- crates/agent_servers/src/acp.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/agent_servers/src/acp.rs b/crates/agent_servers/src/acp.rs index bca47101d6a644a6804acea57ea6d5e887b8bac6..d929d1fc501fb2093f47f8bdeb4d3695b7b87ebf 100644 --- a/crates/agent_servers/src/acp.rs +++ b/crates/agent_servers/src/acp.rs @@ -3,6 +3,7 @@ use acp_thread::AgentConnection; use acp_tools::AcpConnectionRegistry; use action_log::ActionLog; use agent_client_protocol::{self as acp, Agent as _, ErrorCode}; +use agent_settings::AgentSettings; use anyhow::anyhow; use collections::HashMap; use futures::AsyncBufReadExt as _; @@ -10,6 +11,7 @@ use futures::channel::oneshot; use futures::io::BufReader; use project::Project; use serde::Deserialize; +use settings::Settings as _; use std::{any::Any, cell::RefCell}; use std::{path::Path, rc::Rc}; use thiserror::Error; @@ -342,6 +344,28 @@ impl acp::Client for ClientDelegate { arguments: acp::RequestPermissionRequest, ) -> Result { let cx = &mut self.cx.clone(); + + // If always_allow_tool_actions is enabled, then auto-choose the first "Allow" button + if AgentSettings::try_read_global(cx, |settings| settings.always_allow_tool_actions) + .unwrap_or(false) + { + // Don't use AllowAlways, because then if you were to turn off always_allow_tool_actions, + // some tools would (incorrectly) continue to auto-accept. + if let Some(allow_once_option) = arguments.options.iter().find_map(|option| { + if matches!(option.kind, acp::PermissionOptionKind::AllowOnce) { + Some(option.id.clone()) + } else { + None + } + }) { + return Ok(acp::RequestPermissionResponse { + outcome: acp::RequestPermissionOutcome::Selected { + option_id: allow_once_option, + }, + }); + } + } + let rx = self .sessions .borrow()