fix: enable native web search for DeepSeek models in auto mode

Add a thirdPartyNativeSearchModelPatterns list for Anthropic-compatible
providers that support web_search_20250305 but whose model IDs don't
contain "claude". DeepSeek models (deepseek-*) are the first entry.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
bxclib2 2026-05-04 08:10:34 +00:00
parent e99c567dea
commit ebdbeeb549

View File

@ -37,6 +37,11 @@ const WEB_SEARCH_MODES = new Set<WebSearchMode>([
const unsupportedNativeModels = new Set<string>()
// Third-party Anthropic-compatible providers whose model IDs don't contain
// "claude" but do support the web_search_20250305 server tool (e.g. DeepSeek,
// Kimi, Zhipu GLM). Add model patterns here to enable native web search.
const thirdPartyNativeSearchModelPatterns = [/^deepseek-/]
export function isLikelyClaudeModel(model: string | undefined): boolean {
if (!model) {
return false
@ -177,7 +182,10 @@ export function makeWebSearchUnavailableOutput(
function canUseAnthropicNativeWebSearch(model: string | undefined): boolean {
const key = normalizeModelKey(model)
return isLikelyClaudeModel(model) && (!key || !unsupportedNativeModels.has(key))
if (!key || unsupportedNativeModels.has(key)) {
return false
}
return isLikelyClaudeModel(model) || thirdPartyNativeSearchModelPatterns.some(p => p.test(key))
}
function normalizeModelKey(model: string | undefined): string | null {