-
Notifications
You must be signed in to change notification settings - Fork 12.9k
[BUG] Browser Agent ignores settings.json overrides (e.g., maxTurns) #22267
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:
-
packages/core/src/agents/subagent-tool-wrapper.ts
The Browser Agent is explicitly branched out of the standard flow that usesLocalSubagentInvocation:if (definition.name === BROWSER_AGENT_NAME) { return new BrowserAgentInvocation(this.config, ...); }
-
packages/core/src/agents/browser/browserAgentInvocation.ts
Theexecutemethod callscreateBrowserAgentDefinition, passing theconfigobject but omitting the merged definition from the registry. -
packages/core/src/agents/browser/browserAgentFactory.ts
The factory re-runs theBrowserAgentDefinitionconstructor, 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
Labels
Type
Projects
Status