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
- Enable the browser agent
- Ask Gemini to perform any browser task (e.g., "open example.com")
- The agent attempts to call
new_page or navigate_page
- 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,
});
Description
The browser agent is broken. All MCP tools (
new_page,navigate_page,click,take_snapshot, etc.) fail withTool "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
Schedulerconstructor now reads the tool registry viathis.context.toolRegistry(a property from theAgentLoopContextinterface), butagent-scheduler.tscreates the agent-scoped config viaObject.create(config)and only overrides the methodgetToolRegistry():ConfigdefinestoolRegistryas a getter (get toolRegistry()). SinceObject.createinherits from the prototype chain,agentConfig.toolRegistryresolves through the prototype to the originalConfig'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
new_pageornavigate_pageTool "new_page" not found. Did you mean one of: "replace", "read_file", "web_fetch"?Fix
Add
Object.definePropertyto shadow the inherited getter on the agent config: