Skip to content

bug(core): Browser agent fails with "Tool not found" for all MCP tools (new_page, navigate_page, etc.) #21765

@gsquared94

Description

@gsquared94

Description

The browser agent is broken. All MCP tools (new_page, navigate_page, click, take_snapshot, etc.) fail with Tool "new_page" not found. Did you mean one of: "replace", "read_file", "web_fetch"?. The suggested tools are from the main agent's registry, confirming the browser agent's isolated tool registry is being ignored.

Root Cause

Introduced in #21198 (feat(core): Introduce AgentLoopContext).

The Scheduler constructor now reads the tool registry via this.context.toolRegistry (a property from the AgentLoopContext interface), but agent-scheduler.ts creates the agent-scoped config via Object.create(config) and only overrides the method getToolRegistry():

const agentConfig: Config = Object.create(config);
agentConfig.getToolRegistry = () => toolRegistry; // only overrides the method

Config defines toolRegistry as a getter (get toolRegistry()). Since Object.create inherits from the prototype chain, agentConfig.toolRegistry resolves through the prototype to the original Config's getter, which returns the main tool registry, completely bypassing the agent's isolated registry.

This affects all sub-agents that use the agent scheduler, not just the browser agent.

Steps to Reproduce

  1. Enable the browser agent
  2. Ask Gemini to perform any browser task (e.g., "open example.com")
  3. The agent attempts to call new_page or navigate_page
  4. Fails with Tool "new_page" not found. Did you mean one of: "replace", "read_file", "web_fetch"?

Fix

Add Object.defineProperty to shadow the inherited getter on the agent config:

Object.defineProperty(agentConfig, 'toolRegistry', {
  get: () => toolRegistry,
  configurable: true,
});

Metadata

Metadata

Assignees

Labels

area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitystatus/need-triageIssues that need to be triaged by the triage automation.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions