Skip to content

Commit 8de3769

Browse files
Copilotpelikhan
andauthored
Harden SDK tool config helpers
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent a0306bb commit 8de3769

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

pkg/workflow/copilot_engine_sdk_tools.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,17 @@ func extractCopilotAllowedTools(args []string) []string {
149149
}
150150

151151
func buildCopilotSDKToolConfig(workflowData *WorkflowData, toolArgs []string) copilotSDKToolConfig {
152+
if workflowData == nil {
153+
workflowData = &WorkflowData{}
154+
}
155+
tools := workflowData.Tools
152156
config := copilotSDKToolConfig{
153157
Version: copilotSDKToolConfigVersion,
154158
Capabilities: copilotSDKToolCapabilities{
155159
Bash: isCopilotBashToolEnabled(workflowData),
156-
Edit: isCopilotEditToolEnabled(workflowData.Tools, workflowData),
157-
WebFetch: isCopilotToolValueEnabled(workflowData.Tools, "web-fetch"),
158-
WebSearch: isCopilotToolValueEnabled(workflowData.Tools, "web-search"),
160+
Edit: isCopilotEditToolEnabled(tools, workflowData),
161+
WebFetch: isCopilotToolValueEnabled(tools, "web-fetch"),
162+
WebSearch: isCopilotToolValueEnabled(tools, "web-search"),
159163
MCP: hasCopilotSDKMCPTools(workflowData),
160164
CLIProxy: workflowData.ParsedTools != nil && workflowData.ParsedTools.CLIProxy,
161165
},

pkg/workflow/copilot_engine_tools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (e *CopilotEngine) computeCopilotToolArguments(tools map[string]any, safeOu
9494
args = append(args, "--allow-tool", "shell")
9595
} else if bashConfig, hasBash := tools["bash"]; hasBash && isCopilotToolValueEnabled(tools, "bash") {
9696
if bashCommands, ok := bashConfig.([]any); ok {
97-
hasRestrictedBashAllowlist = len(bashCommands) > 0 && (workflowData == nil || !workflowData.BashDisabled)
97+
hasRestrictedBashAllowlist = len(bashCommands) > 0
9898
// Add specific shell commands
9999
for _, cmd := range bashCommands {
100100
if cmdStr, ok := cmd.(string); ok {

0 commit comments

Comments
 (0)