Skip to content

Commit 92d0d5a

Browse files
authored
fix: add --skip-trust to Gemini CLI command to prevent yolo override in AWF sandbox (#28496)
1 parent 16a7fd4 commit 92d0d5a

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

.github/workflows/smoke-gemini.lock.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/workflow/gemini_engine.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ func (e *GeminiEngine) GetExecutionSteps(workflowData *WorkflowData, logFile str
168168
// Without this, Gemini CLI's default approval mode rejects tool calls with "Tool execution denied by policy"
169169
geminiArgs = append(geminiArgs, "--yolo")
170170

171+
// Skip the workspace trust check so --yolo is not overridden to "default" approval mode.
172+
// Gemini CLI v1.x checks whether the working directory is trusted and overrides --yolo
173+
// with "default" approval mode (exit code 55) when the folder is untrusted.
174+
// GEMINI_CLI_TRUST_WORKSPACE=true (also set in the step env) handles the same case via
175+
// environment variable, but --skip-trust is more reliable when AWF's sandbox does not
176+
// forward all host environment variables into the container.
177+
geminiArgs = append(geminiArgs, "--skip-trust")
178+
171179
// Add streaming JSON output (JSONL format, compatible with the log parser)
172180
geminiArgs = append(geminiArgs, "--output-format", "stream-json")
173181

pkg/workflow/gemini_engine_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ func TestGeminiEngineExecution(t *testing.T) {
156156
assert.Contains(t, stepContent, "id: agentic_execution", "Should have agentic_execution ID")
157157
assert.Contains(t, stepContent, "gemini", "Should invoke gemini command")
158158
assert.Contains(t, stepContent, "--yolo", "Should include --yolo flag for auto-approving tool executions")
159+
assert.Contains(t, stepContent, "--skip-trust", "Should include --skip-trust flag to prevent workspace trust check from overriding --yolo")
159160
assert.Contains(t, stepContent, "--output-format stream-json", "Should use streaming JSON output format")
160161
assert.Contains(t, stepContent, `--prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"`, "Should include prompt argument with correct shell quoting")
161162
assert.Contains(t, stepContent, "/tmp/test.log", "Should include log file")

0 commit comments

Comments
 (0)