@@ -23,6 +23,7 @@ import type { AnyDeclarativeTool } from '../../tools/tools.js';
2323import { BrowserManager } from './browserManager.js' ;
2424import {
2525 BrowserAgentDefinition ,
26+ BROWSER_AGENT_NAME ,
2627 type BrowserTaskResultSchema ,
2728} from './browserAgentDefinition.js' ;
2829import { createMcpDeclarativeTools } from './mcpToolWrapper.js' ;
@@ -130,8 +131,28 @@ export async function createBrowserAgentDefinition(
130131 ) ;
131132
132133 // Create configured definition with tools
133- // BrowserAgentDefinition is a factory function - call it with config
134- const baseDefinition = BrowserAgentDefinition ( config , ! visionDisabledReason ) ;
134+ // Attempt to use the existing definition from the registry to preserve overrides
135+ let baseDefinition :
136+ | LocalAgentDefinition < typeof BrowserTaskResultSchema >
137+ | undefined = undefined ;
138+
139+ const registryDef = config
140+ . getAgentRegistry ( )
141+ ?. getDefinition ( BROWSER_AGENT_NAME ) ;
142+
143+ if ( registryDef && registryDef . kind === 'local' ) {
144+ // We know it's a LocalAgentDefinition, we can safely assume it has the right schema
145+ // since we registered it as such.
146+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
147+ baseDefinition = registryDef as unknown as LocalAgentDefinition <
148+ typeof BrowserTaskResultSchema
149+ > ;
150+ }
151+
152+ if ( ! baseDefinition ) {
153+ baseDefinition = BrowserAgentDefinition ( config , ! visionDisabledReason ) ;
154+ }
155+
135156 const definition : LocalAgentDefinition < typeof BrowserTaskResultSchema > = {
136157 ...baseDefinition ,
137158 toolConfig : {
0 commit comments