fix: pass Anthropic yaml addParams, dropParams, defaultParams to getLLMConfig

This commit is contained in:
Roy Noble 2026-04-01 09:19:59 -07:00
parent 419613fdaf
commit 4b83411ac3
3 changed files with 23 additions and 1 deletions

View file

@ -80,7 +80,12 @@ export async function initializeAnthropic({
const anthropicConfig = appConfig?.endpoints?.[EModelEndpoint.anthropic];
const allConfig = appConfig?.endpoints?.all;
const result = getLLMConfig(credentials, clientOptions);
const result = getLLMConfig(credentials, {
...clientOptions,
...(anthropicConfig?.addParams != null && { addParams: anthropicConfig.addParams }),
...(anthropicConfig?.dropParams != null && { dropParams: anthropicConfig.dropParams }),
...(anthropicConfig?.defaultParams != null && { defaultParams: anthropicConfig.defaultParams }),
});
if (anthropicConfig?.streamRate) {
(result.llmConfig as Record<string, unknown>)._lc_stream_delay = anthropicConfig.streamRate;

View file

@ -1535,6 +1535,17 @@ describe('getLLMConfig', () => {
}
});
});
it('should omit native web_search tool when dropParams includes web_search', () => {
const result = getLLMConfig('test-key', {
modelOptions: {
model: 'claude-3-opus',
web_search: true,
},
dropParams: ['web_search'],
});
expect(result.tools).toEqual([]);
});
});
describe('Parameter Precedence and Override Logic', () => {

View file

@ -454,6 +454,12 @@ export const anthropicEndpointSchema = baseEndpointSchema.merge(
vertex: vertexAISchema.optional(),
/** Optional: List of available models */
models: z.array(z.string()).optional(),
/** Additional parameters passed to getLLMConfig (same pattern as custom endpoints) */
addParams: z.record(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(),
/** Parameters excluded from the Anthropic client; e.g. web_search when using LibreChat search tools */
dropParams: z.array(z.string()).optional(),
/** Default parameters applied when model options omit a value */
defaultParams: z.record(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(),
}),
);