-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Description
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 methodConfig 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_pageornavigate_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,
});