google-gemini / google-gemini/gemini-cli

[BUG] Browser Agent ignores settings.json overrides (e.g., maxTurns)

Open
#22,267 3 comments 0 reactions 0 assignees View on GitHub
🔒 maintainer only area/agent kind/bug priority/p2 status/bot-triaged status/need-retesting workstream-rollup
Dominant language
TypeScript
Stars
107k
Forks
14.6k
Avg merge
2d 3h
Merged PRs (30d)
45

Description

# [BUG] Browser Agent ignores `settings.json` overrides (e.g., `maxTurns`)

## What happened?
The Browser Agent completely ignores any configuration overrides provided in the global or project-level `settings.json`. While the `AgentRegistry` correctly reads and merges these settings during initialization, the `BrowserAgentInvocation` and its factory (`browserAgentFactory.ts`) skips the registry and recreate the agent definition from scratch with hardcoded defaults.

## What did you expect to happen?
The Browser Agent should respect settings overrides like `maxTurns`, `maxTimeMinutes`, etc., just like other sub-agents (e.g., `codebase_investigator`). For example, setting `maxTurns: 0` in `settings.json` should cause the agent to terminate immediately upon invocation.

## Client information

Client Information

Platform: Linux (Ubuntu 22.04)
Gemini CLI Version: 0.35.0-nightly.20260311.657f19c1f

## Login information
Google Account (OAuth)

## Anything else we need to know?
### Root Cause
The Browser Agent's unique invocation flow skips the `AgentRegistry` where settings overrides are maintained. Instead of using the pre-merged definition from the registry, it re-instantiates a fresh definition using hardcoded defaults.

**Relevant Files & Code Snippets:**

1. **`packages/core/src/agents/subagent-tool-wrapper.ts`**
The Browser Agent is explicitly branched out of the standard flow that uses `LocalSubagentInvocation`:
```typescript
if (definition.name === BROWSER_AGENT_NAME) {
return new BrowserAgentInvocation(this.config, ...);
}
```

2. **`packages/core/src/agents/browser/browserAgentInvocation.ts`**
The `execute` method calls `createBrowserAgentDefinition`, passing the `config` object but omitting the merged definition from the registry.

3. **`packages/core/src/agents/browser/browserAgentFactory.ts`**
The factory re-runs the `BrowserAgentDefinition` constructor, which returns hardcoded defaults (e.g., `maxTurns: 50`):
```typescript
const baseDefinition = BrowserAgentDefinition(config, !visionDisabledReason);
```

### Suggested Fix
Update `browserAgentFactory.ts` to attempt to retrieve the existing definition from the `AgentRegistry` before falling back to creating a fresh one.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.