From e0d2be35c257097cb9c1ade8ee0768f45b90fb5e Mon Sep 17 00:00:00 2001 From: wangyanfu2 Date: Thu, 5 Mar 2026 17:20:11 +0800 Subject: [PATCH 1/2] fix(tools): make exec tool timeout configurable via config Add TimeoutSeconds field to ExecConfig so the shell command execution timeout can be configured instead of being hardcoded to 60s. - Add TimeoutSeconds int field to ExecConfig in pkg/config/config.go with json/env tags (PICOCLAW_TOOLS_EXEC_TIMEOUT_SECONDS) - Set default value of 60s in DefaultConfig() in pkg/config/defaults.go - Read TimeoutSeconds from config in NewExecToolWithConfig() in pkg/tools/shell.go; falls back to 60s when value is 0 or unset --- pkg/config/config.go | 1 + pkg/config/defaults.go | 1 + pkg/tools/shell.go | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 7a0ec323c..8a5bd883f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -594,6 +594,7 @@ type ExecConfig struct { EnableDenyPatterns bool ` env:"PICOCLAW_TOOLS_EXEC_ENABLE_DENY_PATTERNS" json:"enable_deny_patterns"` CustomDenyPatterns []string ` env:"PICOCLAW_TOOLS_EXEC_CUSTOM_DENY_PATTERNS" json:"custom_deny_patterns"` CustomAllowPatterns []string ` env:"PICOCLAW_TOOLS_EXEC_CUSTOM_ALLOW_PATTERNS" json:"custom_allow_patterns"` + TimeoutSeconds int ` env:"PICOCLAW_TOOLS_EXEC_TIMEOUT_SECONDS" json:"timeout_seconds"` // 0 means use default (60s) } type SkillsToolsConfig struct { diff --git a/pkg/config/defaults.go b/pkg/config/defaults.go index e87d7aa0a..c4c04d41a 100644 --- a/pkg/config/defaults.go +++ b/pkg/config/defaults.go @@ -386,6 +386,7 @@ func DefaultConfig() *Config { Enabled: true, }, EnableDenyPatterns: true, + TimeoutSeconds: 60, }, Skills: SkillsToolsConfig{ ToolConfig: ToolConfig{ diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index a0c83eb1e..2ea58b259 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -131,9 +131,14 @@ func NewExecToolWithConfig(workingDir string, restrict bool, config *config.Conf denyPatterns = append(denyPatterns, defaultDenyPatterns...) } + timeout := 60 * time.Second + if config != nil && config.Tools.Exec.TimeoutSeconds > 0 { + timeout = time.Duration(config.Tools.Exec.TimeoutSeconds) * time.Second + } + return &ExecTool{ workingDir: workingDir, - timeout: 60 * time.Second, + timeout: timeout, denyPatterns: denyPatterns, allowPatterns: nil, customAllowPatterns: customAllowPatterns, From 65e1434e1b2690c72c83ade2969e740766e6c2a3 Mon Sep 17 00:00:00 2001 From: wangyanfu2 Date: Fri, 6 Mar 2026 11:19:25 +0800 Subject: [PATCH 2/2] style: fix gofmt formatting in ExecConfig struct Remove extra trailing whitespace between struct tag and inline comment on TimeoutSeconds field to comply with gofmt formatting rules. --- pkg/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 8a5bd883f..5f389f511 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -594,7 +594,7 @@ type ExecConfig struct { EnableDenyPatterns bool ` env:"PICOCLAW_TOOLS_EXEC_ENABLE_DENY_PATTERNS" json:"enable_deny_patterns"` CustomDenyPatterns []string ` env:"PICOCLAW_TOOLS_EXEC_CUSTOM_DENY_PATTERNS" json:"custom_deny_patterns"` CustomAllowPatterns []string ` env:"PICOCLAW_TOOLS_EXEC_CUSTOM_ALLOW_PATTERNS" json:"custom_allow_patterns"` - TimeoutSeconds int ` env:"PICOCLAW_TOOLS_EXEC_TIMEOUT_SECONDS" json:"timeout_seconds"` // 0 means use default (60s) + TimeoutSeconds int ` env:"PICOCLAW_TOOLS_EXEC_TIMEOUT_SECONDS" json:"timeout_seconds"` // 0 means use default (60s) } type SkillsToolsConfig struct {