diff --git a/pkg/workflow/codex_engine.go b/pkg/workflow/codex_engine.go index 7a9d9b3fe9..649a7d6825 100644 --- a/pkg/workflow/codex_engine.go +++ b/pkg/workflow/codex_engine.go @@ -308,15 +308,7 @@ mkdir -p "$CODEX_HOME/logs" } } else { // Build the command without AWF wrapping - // Determine which command to use - var commandName string - if workflowData.EngineConfig != nil && workflowData.EngineConfig.Command != "" { - commandName = workflowData.EngineConfig.Command - codexEngineLog.Printf("Using custom command: %s", commandName) - } else { - commandName = "codex" - } - + // Reuse commandName already determined above if workflowData.AgentFile != "" { agentPath := ResolveAgentFilePath(workflowData.AgentFile) command = fmt.Sprintf(`set -o pipefail diff --git a/pkg/workflow/compiler_types.go b/pkg/workflow/compiler_types.go index 256204ef24..a990808289 100644 --- a/pkg/workflow/compiler_types.go +++ b/pkg/workflow/compiler_types.go @@ -325,7 +325,7 @@ type SafeOutputsConfig struct { CreatePullRequests *CreatePullRequestsConfig `yaml:"create-pull-requests,omitempty"` CreatePullRequestReviewComments *CreatePullRequestReviewCommentsConfig `yaml:"create-pull-request-review-comments,omitempty"` CreateCodeScanningAlerts *CreateCodeScanningAlertsConfig `yaml:"create-code-scanning-alerts,omitempty"` - AutofixCodeScanningAlert *AutofixCodeScanningAlertConfig `yaml:"autofix-code-scanning-alert,omitempty"` + AutofixCodeScanningAlert *AutofixCodeScanningAlertConfig `yaml:"autofix-code-scanning-alert,omitempty"` AddLabels *AddLabelsConfig `yaml:"add-labels,omitempty"` AddReviewer *AddReviewerConfig `yaml:"add-reviewer,omitempty"` AssignMilestone *AssignMilestoneConfig `yaml:"assign-milestone,omitempty"` diff --git a/pkg/workflow/copilot_engine_execution.go b/pkg/workflow/copilot_engine_execution.go index c1491cc857..b35661d6a9 100644 --- a/pkg/workflow/copilot_engine_execution.go +++ b/pkg/workflow/copilot_engine_execution.go @@ -148,31 +148,32 @@ func (e *CopilotEngine) GetExecutionSteps(workflowData *WorkflowData, logFile st modelEnvVar = constants.EnvVarModelAgentCopilot } - if sandboxEnabled { - // Build base command - var baseCommand string - - // Check if custom command is specified - var commandName string - if workflowData.EngineConfig != nil && workflowData.EngineConfig.Command != "" { - commandName = workflowData.EngineConfig.Command - copilotExecLog.Printf("Using custom command: %s", commandName) + // Determine which command to use (once for both sandbox and non-sandbox modes) + var commandName string + if workflowData.EngineConfig != nil && workflowData.EngineConfig.Command != "" { + commandName = workflowData.EngineConfig.Command + copilotExecLog.Printf("Using custom command: %s", commandName) + } else if sandboxEnabled { + // For SRT: use locally installed package without -y flag to avoid internet fetch + // For AWF: use the installed binary directly + if isSRTEnabled(workflowData) { + // Use node explicitly to invoke copilot CLI to ensure env vars propagate correctly through sandbox + // The .bin/copilot shell wrapper doesn't properly pass environment variables through bubblewrap + // Environment variables are explicitly exported in the SRT wrapper to propagate through sandbox + commandName = "node ./node_modules/.bin/copilot" } else { - // For SRT: use locally installed package without -y flag to avoid internet fetch - // For AWF: use the installed binary directly - if isSRTEnabled(workflowData) { - // Use node explicitly to invoke copilot CLI to ensure env vars propagate correctly through sandbox - // The .bin/copilot shell wrapper doesn't properly pass environment variables through bubblewrap - // Environment variables are explicitly exported in the SRT wrapper to propagate through sandbox - commandName = "node ./node_modules/.bin/copilot" - } else { - // AWF - use the copilot binary installed by the installer script - // The binary is mounted into the AWF container from /usr/local/bin/copilot - commandName = "/usr/local/bin/copilot" - } + // AWF - use the copilot binary installed by the installer script + // The binary is mounted into the AWF container from /usr/local/bin/copilot + commandName = "/usr/local/bin/copilot" } + } else { + // Non-sandbox mode: use standard copilot command + commandName = "copilot" + } - baseCommand = fmt.Sprintf("%s %s", commandName, shellJoinArgs(copilotArgs)) + if sandboxEnabled { + // Build base command + baseCommand := fmt.Sprintf("%s %s", commandName, shellJoinArgs(copilotArgs)) // Add conditional model flag if needed if needsModelFlag { @@ -181,15 +182,6 @@ func (e *CopilotEngine) GetExecutionSteps(workflowData *WorkflowData, logFile st copilotCommand = baseCommand } } else { - // When sandbox is disabled, determine command to use - var commandName string - if workflowData.EngineConfig != nil && workflowData.EngineConfig.Command != "" { - commandName = workflowData.EngineConfig.Command - copilotExecLog.Printf("Using custom command: %s", commandName) - } else { - commandName = "copilot" - } - baseCommand := fmt.Sprintf("%s %s", commandName, shellJoinArgs(copilotArgs)) // Add conditional model flag if needed