Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions cmd/entire/cli/e2e_test/agent_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"fmt"
"os"
"os/exec"
"strings"
"time"
)

Expand Down Expand Up @@ -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
Copy link

Copilot AI Feb 18, 2026

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-tools was removed.

Suggested change
// "ShellTool(git commit -m "msg")"), causing the agent to hang waiting
// "ShellTool(git commit -m 'msg')"), causing the agent to hang waiting

Copilot uses AI. Check for mistakes.
// 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
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tools is now unused for the Gemini runner (everything is auto-approved via -y), which makes RunPromptWithTools misleading and may trigger unparam/unused-arg linting when the e2e build tag is included. Consider renaming the parameter to _ (or explicitly consuming it with a short comment) and documenting that tool allowlisting isn’t supported for Gemini in this runner.

Copilot uses AI. Check for mistakes.

// Create context with timeout
Expand All @@ -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
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting ENTIRE_TEST_TTY=0 here prevents interactive git-hook prompts during agent-driven git commit -m, but this same hang risk applies to other agent runners too (e.g., Claude). Consider applying the same environment override consistently for all agent subprocesses so e2e behavior doesn’t depend on which agent is selected or whether the developer has a real /dev/tty available.

Copilot uses AI. Check for mistakes.

var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
Expand Down