Skip to content

Commit 1b5b6d4

Browse files
fix(core): respect browser agent settings overrides from registry
Fixes #22267
1 parent aacbb77 commit 1b5b6d4

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

packages/core/src/agents/browser/browserAgentFactory.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type { AnyDeclarativeTool } from '../../tools/tools.js';
2323
import { BrowserManager } from './browserManager.js';
2424
import {
2525
BrowserAgentDefinition,
26+
BROWSER_AGENT_NAME,
2627
type BrowserTaskResultSchema,
2728
} from './browserAgentDefinition.js';
2829
import { 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

Comments
 (0)