Skip to content

Commit f600829

Browse files
authored
Merge pull request #1157 from wangyanfu2/fix-config-shell-command-exec-timeout
fix(tools): make exec tool timeout configurable via config
2 parents 8581d46 + 65e1434 commit f600829

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ type ExecConfig struct {
594594
EnableDenyPatterns bool ` env:"PICOCLAW_TOOLS_EXEC_ENABLE_DENY_PATTERNS" json:"enable_deny_patterns"`
595595
CustomDenyPatterns []string ` env:"PICOCLAW_TOOLS_EXEC_CUSTOM_DENY_PATTERNS" json:"custom_deny_patterns"`
596596
CustomAllowPatterns []string ` env:"PICOCLAW_TOOLS_EXEC_CUSTOM_ALLOW_PATTERNS" json:"custom_allow_patterns"`
597+
TimeoutSeconds int ` env:"PICOCLAW_TOOLS_EXEC_TIMEOUT_SECONDS" json:"timeout_seconds"` // 0 means use default (60s)
597598
}
598599

599600
type SkillsToolsConfig struct {

pkg/config/defaults.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ func DefaultConfig() *Config {
386386
Enabled: true,
387387
},
388388
EnableDenyPatterns: true,
389+
TimeoutSeconds: 60,
389390
},
390391
Skills: SkillsToolsConfig{
391392
ToolConfig: ToolConfig{

pkg/tools/shell.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,14 @@ func NewExecToolWithConfig(workingDir string, restrict bool, config *config.Conf
131131
denyPatterns = append(denyPatterns, defaultDenyPatterns...)
132132
}
133133

134+
timeout := 60 * time.Second
135+
if config != nil && config.Tools.Exec.TimeoutSeconds > 0 {
136+
timeout = time.Duration(config.Tools.Exec.TimeoutSeconds) * time.Second
137+
}
138+
134139
return &ExecTool{
135140
workingDir: workingDir,
136-
timeout: 60 * time.Second,
141+
timeout: timeout,
137142
denyPatterns: denyPatterns,
138143
allowPatterns: nil,
139144
customAllowPatterns: customAllowPatterns,

0 commit comments

Comments
 (0)