From c4e0b24b147e51b2408ee579a1baaef8d19846c2 Mon Sep 17 00:00:00 2001 From: shikihane Date: Thu, 5 Mar 2026 16:20:11 +0800 Subject: [PATCH] feat(tools): support toggling send_file tool via config Add SendFileConfig with Enabled field to ToolsConfig, defaulting to true. Wrap send_file tool registration in loop.go with the config check, consistent with the pattern used by other tools. Co-Authored-By: Claude Opus 4.6 --- pkg/agent/loop.go | 16 +++++++++------- pkg/config/config.go | 3 +++ pkg/config/defaults.go | 3 +++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index 7bee94369..90bb01d34 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -171,13 +171,15 @@ func registerSharedTools( } // Send file tool (outbound media via MediaStore — store injected later by SetMediaStore) - sendFileTool := tools.NewSendFileTool( - agent.Workspace, - cfg.Agents.Defaults.RestrictToWorkspace, - cfg.Agents.Defaults.GetMaxMediaSize(), - nil, - ) - agent.Tools.Register(sendFileTool) + if cfg.Tools.IsToolEnabled("send_file") { + sendFileTool := tools.NewSendFileTool( + agent.Workspace, + cfg.Agents.Defaults.RestrictToWorkspace, + cfg.Agents.Defaults.GetMaxMediaSize(), + nil, + ) + agent.Tools.Register(sendFileTool) + } // Skill discovery and installation tools skills_enabled := cfg.Tools.IsToolEnabled("skills") diff --git a/pkg/config/config.go b/pkg/config/config.go index 7a0ec323c..90a6cd787 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -626,6 +626,7 @@ type ToolsConfig struct { ListDir ToolConfig `json:"list_dir" envPrefix:"PICOCLAW_TOOLS_LIST_DIR_"` Message ToolConfig `json:"message" envPrefix:"PICOCLAW_TOOLS_MESSAGE_"` ReadFile ToolConfig `json:"read_file" envPrefix:"PICOCLAW_TOOLS_READ_FILE_"` + SendFile ToolConfig `json:"send_file" envPrefix:"PICOCLAW_TOOLS_SEND_FILE_"` Spawn ToolConfig `json:"spawn" envPrefix:"PICOCLAW_TOOLS_SPAWN_"` SPI ToolConfig `json:"spi" envPrefix:"PICOCLAW_TOOLS_SPI_"` Subagent ToolConfig `json:"subagent" envPrefix:"PICOCLAW_TOOLS_SUBAGENT_"` @@ -899,6 +900,8 @@ func (t *ToolsConfig) IsToolEnabled(name string) bool { return t.Subagent.Enabled case "web_fetch": return t.WebFetch.Enabled + case "send_file": + return t.SendFile.Enabled case "write_file": return t.WriteFile.Enabled case "mcp": diff --git a/pkg/config/defaults.go b/pkg/config/defaults.go index e87d7aa0a..77741d59a 100644 --- a/pkg/config/defaults.go +++ b/pkg/config/defaults.go @@ -403,6 +403,9 @@ func DefaultConfig() *Config { TTLSeconds: 300, }, }, + SendFile: ToolConfig{ + Enabled: true, + }, MCP: MCPConfig{ ToolConfig: ToolConfig{ Enabled: false,