fix(agents): emit --dangerously-skip-permissions for Claude CLI passthrough (#1262)

* fix(agents): emit --dangerously-skip-permissions for Claude CLI passthrough (#1261)

Claude ACP declared empty PermSettings in passthrough mode, so the launch path's
PermissionValues map (which carries the profile's DangerouslySkipPermissions
toggle) had no matching CLI-flag mapping to emit. Bypass / auto-approve was
silently ignored. Wire the permission setting to --dangerously-skip-permissions
and skip the key in seedCLIFlags so the toggle does not double-surface in the
curated cli_flags list.

* test(agents): use PermissionKeyDangerouslySkipPermissions constant in claude_acp_test

* test(agents): use constant in claude_acp_test failure message too

---------

Co-authored-by: Kandev Agent <agent@kandev.dev>
This commit is contained in:
João Salavisa
2026-06-03 10:14:03 +01:00
committed by GitHub
parent 0b7bbd93d5
commit 5143a76e35
4 changed files with 79 additions and 3 deletions
@@ -250,6 +250,15 @@ const PermissionKeyAutoApprove = "auto_approve"
// run-everything). Separate from PermissionKeyAutoApprove (agentctl ACP approval).
const PermissionKeyCursorForce = "cursor_force"
// PermissionKeyDangerouslySkipPermissions is wired to the profile's
// DangerouslySkipPermissions column (a dedicated bool, not the cli_flags list).
// Agents whose CLI accepts --dangerously-skip-permissions (or equivalent)
// declare a PermissionSetting under this key with ApplyMethod=cli_flag so the
// passthrough Settings() pass emits the flag from the profile bool. The
// catalog seeder excludes this key to avoid duplicating the toggle into the
// curated cli_flags list (which would also double-emit the flag at launch).
const PermissionKeyDangerouslySkipPermissions = "dangerously_skip_permissions"
// PermissionSetting defines metadata for a permission setting option.
type PermissionSetting struct {
Supported bool `json:"supported"`
@@ -18,6 +18,21 @@ var claudeACPLogoDark []byte
const claudeACPPkg = "@agentclientprotocol/claude-agent-acp"
// claudeACPPermSettings maps the profile DangerouslySkipPermissions toggle to
// the Claude Code CLI's --dangerously-skip-permissions flag in passthrough mode.
// ACP (non-passthrough) Claude does not consume this flag; permission bypass
// there goes through agentctl's auto-approve channel.
var claudeACPPermSettings = map[string]PermissionSetting{
PermissionKeyDangerouslySkipPermissions: {
Supported: true,
Default: false,
Label: "Skip permission prompts",
Description: "Pass --dangerously-skip-permissions so Claude Code does not prompt for tool approvals.",
ApplyMethod: PermissionApplyMethodCLIFlag,
CLIFlag: "--dangerously-skip-permissions",
},
}
var (
_ Agent = (*ClaudeACP)(nil)
_ PassthroughAgent = (*ClaudeACP)(nil)
@@ -34,7 +49,7 @@ type ClaudeACP struct {
func NewClaudeACP() *ClaudeACP {
return &ClaudeACP{
StandardPassthrough: StandardPassthrough{
PermSettings: emptyPermSettings,
PermSettings: claudeACPPermSettings,
Cfg: PassthroughConfig{
Supported: true,
Label: "CLI Passthrough",
@@ -160,7 +175,7 @@ func (a *ClaudeACP) InstallScript() string {
func (a *ClaudeACP) BillingType() usage.BillingType { return claudeBillingType() }
func (a *ClaudeACP) PermissionSettings() map[string]PermissionSetting {
return emptyPermSettings
return claudeACPPermSettings
}
// InferenceConfig returns configuration for one-shot inference using ACP.
@@ -0,0 +1,45 @@
package agents
import (
"strings"
"testing"
)
func TestClaudeACPPermissionSettingsSkipPermissions(t *testing.T) {
settings := NewClaudeACP().PermissionSettings()
setting, ok := settings[PermissionKeyDangerouslySkipPermissions]
if !ok {
t.Fatalf("PermissionSettings() missing key %q", PermissionKeyDangerouslySkipPermissions)
}
if !setting.Supported {
t.Error("dangerously_skip_permissions must be Supported")
}
if setting.ApplyMethod != PermissionApplyMethodCLIFlag {
t.Errorf("ApplyMethod = %q, want %q", setting.ApplyMethod, PermissionApplyMethodCLIFlag)
}
if setting.CLIFlag != "--dangerously-skip-permissions" {
t.Errorf("CLIFlag = %q, want --dangerously-skip-permissions", setting.CLIFlag)
}
}
// Passthrough launch path drives the flag via PermissionValues. Verify the
// resulting command includes --dangerously-skip-permissions when the toggle is
// on, and excludes it otherwise. Regression coverage for issue #1261.
func TestClaudeACPBuildPassthroughCommandSkipPermissions(t *testing.T) {
c := NewClaudeACP()
without := strings.Join(c.BuildPassthroughCommand(PassthroughOptions{}).Args(), " ")
if strings.Contains(without, "--dangerously-skip-permissions") {
t.Errorf("default passthrough command must not include --dangerously-skip-permissions, got %q", without)
}
with := strings.Join(
c.BuildPassthroughCommand(PassthroughOptions{
PermissionValues: map[string]bool{PermissionKeyDangerouslySkipPermissions: true},
}).Args(),
" ",
)
if !strings.Contains(with, "--dangerously-skip-permissions") {
t.Errorf("passthrough command with dangerously_skip_permissions=true must include --dangerously-skip-permissions, got %q", with)
}
}
@@ -82,10 +82,17 @@ func (c *Controller) CreateProfile(ctx context.Context, req CreateProfileRequest
func seedCLIFlags(agent agents.Agent) []models.CLIFlag {
settings := agents.CatalogPermissionSettings(agent)
flags := make([]models.CLIFlag, 0, len(settings))
for _, s := range settings {
for key, s := range settings {
if !s.Supported || s.ApplyMethod != agents.PermissionApplyMethodCLIFlag || s.CLIFlag == "" {
continue
}
// dangerously_skip_permissions is wired to the profile's dedicated
// DangerouslySkipPermissions column; the passthrough launch path emits
// the flag via PermissionValues. Seeding it as a curated cli_flag too
// would surface a duplicate toggle in the UI and double-emit the flag.
if key == agents.PermissionKeyDangerouslySkipPermissions {
continue
}
flagText := s.CLIFlag
if s.CLIFlagValue != "" {
flagText = s.CLIFlag + " " + s.CLIFlagValue