Skip to content

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

@hsm207

Description

@hsm207

[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:

    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):

    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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitypriority/p2Important but can be addressed in a future release.workstream-rollupLabel used to tag epics and features that are associated with one of the three primary workstreams🔒 maintainer only⛔ Do not contribute. Internal roadmap item.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions