From ac35dc6130633f827c27703d523dccb68f725b82 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sat, 16 May 2026 15:55:04 +0200 Subject: [PATCH 01/10] fix: unblock all commands in bash tool --- internal/agent/tools/bash.go | 106 +------------------------------ internal/agent/tools/bash.md.tpl | 2 +- 2 files changed, 2 insertions(+), 106 deletions(-) diff --git a/internal/agent/tools/bash.go b/internal/agent/tools/bash.go index 35093ac3..81d78236 100644 --- a/internal/agent/tools/bash.go +++ b/internal/agent/tools/bash.go @@ -65,7 +65,6 @@ var bashDescriptionTpl = template.Must( ) type bashDescriptionData struct { - BannedCommands string MaxOutputLength int Attribution config.Attribution ModelID string @@ -73,84 +72,9 @@ type bashDescriptionData struct { GhAvailable bool } -var bannedCommands = []string{ - // Network/Download tools - "alias", - "aria2c", - "axel", - "chrome", - "curl", - "curlie", - "firefox", - "http-prompt", - "httpie", - "links", - "lynx", - "nc", - "safari", - "scp", - "ssh", - "telnet", - "w3m", - "wget", - "xh", - - // System administration - "doas", - "su", - "sudo", - - // Package managers - "apk", - "apt", - "apt-cache", - "apt-get", - "dnf", - "dpkg", - "emerge", - "home-manager", - "makepkg", - "opkg", - "pacman", - "paru", - "pkg", - "pkg_add", - "pkg_delete", - "portage", - "rpm", - "yay", - "yum", - "zypper", - - // System modification - "at", - "batch", - "chkconfig", - "crontab", - "fdisk", - "mkfs", - "mount", - "parted", - "service", - "systemctl", - "umount", - - // Network configuration - "firewall-cmd", - "ifconfig", - "ip", - "iptables", - "netstat", - "pfctl", - "route", - "ufw", -} - func bashDescription(attribution *config.Attribution, modelID string) string { - bannedCommandsStr := strings.Join(bannedCommands, ", ") var out bytes.Buffer if err := bashDescriptionTpl.Execute(&out, bashDescriptionData{ - BannedCommands: bannedCommandsStr, MaxOutputLength: MaxOutputLength, Attribution: *attribution, ModelID: modelID, @@ -164,35 +88,7 @@ func bashDescription(attribution *config.Attribution, modelID string) string { } func blockFuncs() []shell.BlockFunc { - return []shell.BlockFunc{ - shell.CommandsBlocker(bannedCommands), - - // System package managers - shell.ArgumentsBlocker("apk", []string{"add"}, nil), - shell.ArgumentsBlocker("apt", []string{"install"}, nil), - shell.ArgumentsBlocker("apt-get", []string{"install"}, nil), - shell.ArgumentsBlocker("dnf", []string{"install"}, nil), - shell.ArgumentsBlocker("pacman", nil, []string{"-S"}), - shell.ArgumentsBlocker("pkg", []string{"install"}, nil), - shell.ArgumentsBlocker("yum", []string{"install"}, nil), - shell.ArgumentsBlocker("zypper", []string{"install"}, nil), - - // Language-specific package managers - shell.ArgumentsBlocker("brew", []string{"install"}, nil), - shell.ArgumentsBlocker("cargo", []string{"install"}, nil), - shell.ArgumentsBlocker("gem", []string{"install"}, nil), - shell.ArgumentsBlocker("go", []string{"install"}, nil), - shell.ArgumentsBlocker("npm", []string{"install"}, []string{"--global"}), - shell.ArgumentsBlocker("npm", []string{"install"}, []string{"-g"}), - shell.ArgumentsBlocker("pip", []string{"install"}, []string{"--user"}), - shell.ArgumentsBlocker("pip3", []string{"install"}, []string{"--user"}), - shell.ArgumentsBlocker("pnpm", []string{"add"}, []string{"--global"}), - shell.ArgumentsBlocker("pnpm", []string{"add"}, []string{"-g"}), - shell.ArgumentsBlocker("yarn", []string{"global", "add"}, nil), - - // `go test -exec` can run arbitrary commands - shell.ArgumentsBlocker("go", []string{"test"}, []string{"-exec"}), - } + return nil } func NewBashTool(permissions permission.Service, workingDir, spillDir string, attribution *config.Attribution, modelID string) fantasy.AgentTool { diff --git a/internal/agent/tools/bash.md.tpl b/internal/agent/tools/bash.md.tpl index f850fac9..9622d14c 100644 --- a/internal/agent/tools/bash.md.tpl +++ b/internal/agent/tools/bash.md.tpl @@ -8,7 +8,7 @@ Common shell builtins and core utils available on Windows. 1. Directory Verification: If creating directories/files, use LS tool to verify parent exists -2. Security Check: Banned commands ({{ .BannedCommands }}) return error - explain to user. Safe read-only commands execute without prompts +2. Security Check: Safe read-only commands execute without prompts 3. Command Execution: Execute with proper quoting, capture output 4. Auto-Background: Commands exceeding 1 minute (default, configurable via `auto_background_after`) automatically move to background and return shell ID 5. Output Processing: Truncate if exceeds {{ .MaxOutputLength }} characters. The truncation marker names a file holding the complete output - read it with the view tool when the omitted middle matters -- 2.53.0