-
Notifications
You must be signed in to change notification settings - Fork 181
fix: Gemini e2e tests stall #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,6 @@ import ( | |
| "fmt" | ||
| "os" | ||
| "os/exec" | ||
| "strings" | ||
| "time" | ||
| ) | ||
|
|
||
|
|
@@ -264,28 +263,16 @@ func (r *GeminiCLIRunner) RunPrompt(ctx context.Context, workDir string, prompt | |
| } | ||
|
|
||
| func (r *GeminiCLIRunner) RunPromptWithTools(ctx context.Context, workDir string, prompt string, tools []string) (*AgentResult, error) { | ||
| // Build command: gemini -m <model> -p "<prompt>" --approval-mode auto_edit --allowed-tools <tools> | ||
| // --approval-mode auto_edit: auto-approves edit tools (write_file, replace) while prompting for others | ||
| // --allowed-tools: comma-separated list of tools that bypass confirmation (e.g., git commands) | ||
| // Build command: gemini -m <model> -p "<prompt>" --yolo | ||
| // --yolo (-y): auto-approves all tools, required for non-interactive e2e tests | ||
| // Note: --approval-mode auto_edit + --allowed-tools doesn't work because | ||
| // tool matching is exact (e.g., "ShellTool(git commit)" won't match | ||
| // "ShellTool(git commit -m "msg")"), causing the agent to hang waiting | ||
| // for approval in a non-interactive context. | ||
| args := []string{ | ||
| "-m", r.Model, | ||
| "-p", prompt, | ||
| "--approval-mode", "auto_edit", | ||
| } | ||
|
|
||
| // Add default git tools that should be allowed without confirmation | ||
| defaultAllowedTools := []string{ | ||
| "ShellTool(git status)", | ||
| "ShellTool(git add)", | ||
| "ShellTool(git commit)", | ||
| "ShellTool(git diff)", | ||
| "ShellTool(git log)", | ||
| } | ||
|
|
||
| // Merge with any additional tools passed in | ||
| allTools := append(defaultAllowedTools, tools...) | ||
| if len(allTools) > 0 { | ||
| args = append(args, "--allowed-tools", strings.Join(allTools, ",")) | ||
| "-y", | ||
| } | ||
|
Comment on lines
265
to
276
|
||
|
|
||
| // Create context with timeout | ||
|
|
@@ -295,6 +282,9 @@ func (r *GeminiCLIRunner) RunPromptWithTools(ctx context.Context, workDir string | |
| //nolint:gosec // args are constructed from trusted config, not user input | ||
| cmd := exec.CommandContext(ctx, "gemini", args...) | ||
| cmd.Dir = workDir | ||
| // ENTIRE_TEST_TTY=0 prevents git hooks (prepare-commit-msg) from trying to | ||
| // read /dev/tty for interactive confirmation, which hangs in non-interactive tests. | ||
| cmd.Env = append(os.Environ(), "ENTIRE_TEST_TTY=0") | ||
|
Comment on lines
+285
to
+287
|
||
|
|
||
| var stdout, stderr bytes.Buffer | ||
| cmd.Stdout = &stdout | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The explanatory comment here is hard to read because of nested quotes (e.g.,
"... -m "msg""). Rephrasing the example (or using single quotes in the example strings) would avoid confusion when someone later revisits why--allowed-toolswas removed.