Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(agent): stop filtering Pi extension tools via hardcoded --tools allowlist (#2379) (#2381)
Kagura702c48209b6a
diff --git a/server/pkg/agent/pi.go b/server/pkg/agent/pi.goindex ecb7438864..26e441c3ac 100644--- a/server/pkg/agent/pi.go+++ b/server/pkg/agent/pi.go@@ -316,7 +316,6 @@ var piBlockedArgs = map[string]blockedArgMode{// --session <path> session log file (created upfront, reused on resume)// --provider <name> provider, when Model is "provider/id"// --model <id> model identifier-// --tools read,bash,... explicit tool allowlist (pi has no --yolo)// --append-system-prompt <s> extra system instructions//// Custom args appended before the positional prompt. The prompt is a@@ -338,7 +337,11 @@ func buildPiArgs(prompt, sessionPath string, opts ExecOptions, logger *slog.Loggargs = append(args, "--model", model)}}- args = append(args, "--tools", "read,bash,edit,write,grep,find,ls")+ // Note: we intentionally do NOT pass --tools here. Omitting it lets+ // Pi use its full tool registry, including user-installed extension+ // tools. Passing --tools acts as a restrictive allowlist that+ // silently filters out extension-registered tools (#2379).+ // Users who want to restrict tools can do so via custom_args.if opts.SystemPrompt != "" {args = append(args, "--append-system-prompt", opts.SystemPrompt)}diff --git a/server/pkg/agent/pi_test.go b/server/pkg/agent/pi_test.gonew file mode 100644index 0000000000..c524fb7d75--- /dev/null+++ b/server/pkg/agent/pi_test.go@@ -0,0 +1,55 @@+package agent++import (+ "log/slog"+ "strings"+ "testing"+)++func TestBuildPiArgsNoToolAllowlist(t *testing.T) {+ // Extension tools registered via Pi's registerTool() must not be+ // filtered out by a hardcoded --tools allowlist. Omitting --tools+ // lets Pi use its full tool registry. See #2379.+ args := buildPiArgs("test prompt", "/tmp/session.jsonl", ExecOptions{}, slog.Default())+ for i, arg := range args {+ if arg == "--tools" {+ t.Errorf("buildPiArgs emits --tools %q; should not restrict tool registry (see #2379)", args[i+1])+ }+ }+}++func TestBuildPiArgsBasicFlags(t *testing.T) {+ args := buildPiArgs("hello world", "/tmp/s.jsonl", ExecOptions{+ Model: "anthropic/claude-sonnet-4-20250514",+ SystemPrompt: "be helpful",+ }, slog.Default())++ joined := strings.Join(args, " ")+ for _, want := range []string{"-p", "--mode json", "--session /tmp/s.jsonl", "--provider anthropic", "--model claude-sonnet-4-20250514", "--append-system-prompt"} {+ if !strings.Contains(joined, want) {+ t.Errorf("expected %q in args, got: %v", want, args)+ }+ }++ // Prompt must be the last positional argument.+ if args[len(args)-1] != "hello world" {+ t.Errorf("prompt should be last arg, got %q", args[len(args)-1])+ }+}++func TestBuildPiArgsCustomArgsAppended(t *testing.T) {+ // Users can still restrict tools via custom_args if desired.+ args := buildPiArgs("prompt", "/tmp/s.jsonl", ExecOptions{+ CustomArgs: []string{"--tools", "read,bash"},+ }, slog.Default())++ found := false+ for i, arg := range args {+ if arg == "--tools" && i+1 < len(args) && args[i+1] == "read,bash" {+ found = true+ }+ }+ if !found {+ t.Errorf("custom --tools should pass through via custom_args, got: %v", args)+ }+}