{"record":{"id":"535ee10f4f1d4c80","repo":"mastra-ai/mastra","slug":"web-search-unsupported-provider","errorCode":"WEB_SEARCH_UNSUPPORTED_PROVIDER","errorMessage":"The built-in webSearchTool supports OpenAI, Anthropic, Google, and xAI models. Could not infer a supported provider from \"${provider}\".","messagePattern":"The built-in webSearchTool supports OpenAI, Anthropic, Google, and xAI models\\. Could not infer a supported provider from \"(.+?)\"\\.","errorType":"exception","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/tools/builtin/web-search.ts","lineNumber":41,"sourceCode":"    tool === webSearchTool ||\n    (typeof tool === 'object' && tool !== null && (tool as WebSearchToolPlaceholder)[WEB_SEARCH_TOOL_MARKER] === true)\n  );\n}\n\nexport function normalizeWebSearchProvider(providerOrModel: unknown): WebSearchProvider {\n  const provider = getProviderString(providerOrModel);\n  const supportedProviders = new Set<WebSearchProvider>(['openai', 'anthropic', 'google', 'xai']);\n\n  if (supportedProviders.has(provider as WebSearchProvider)) {\n    return provider as WebSearchProvider;\n  }\n\n  const routerProvider = getRouterProvider(provider);\n  if (supportedProviders.has(routerProvider as WebSearchProvider)) {\n    return routerProvider as WebSearchProvider;\n  }\n\n  throw new MastraError({\n    id: 'WEB_SEARCH_UNSUPPORTED_PROVIDER',\n    domain: ErrorDomain.AGENT,\n    category: ErrorCategory.USER,\n    details: {\n      provider,\n    },\n    text: `The built-in webSearchTool supports OpenAI, Anthropic, Google, and xAI models. Could not infer a supported provider from \"${provider}\".`,\n  });\n}\n\nexport function createWebSearchProviderTool(provider: WebSearchProvider): ProviderDefinedTool {\n  const tool = getWebSearchProviderTool(provider);\n  return {\n    type: 'provider-defined',\n    id: tool.id,\n    name: tool.name,\n    args: {},\n  } as ProviderDefinedTool;","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/tools/builtin/web-search.ts#L23-L59","documentation":"webSearchTool is a placeholder that Mastra resolves at agent-assembly time into a provider-native web-search tool. The provider must be one of OpenAI, Anthropic, Google, or xAI, inferred either directly from a string or from a model object's provider (with router-provider mapping). normalizeWebSearchProvider throws this MastraError (AGENT domain, USER category) when the inferred provider string is not in the supported set.","triggerScenarios":"Passing webSearchTool in an agent's tools list while the configured model is from an unsupported provider (e.g. Mistral, Groq, Cohere, an openai-compatible endpoint that cannot be mapped, or a plain string model id like 'my-model' with no provider prefix).","commonSituations":"Developers assume webSearchTool works with any LLM provider; using a gateway/router model string whose provider maps to something outside the four supported families; typos in provider strings like 'OpenAI' or 'openai.chat'.","solutions":["Switch the agent's model to one from OpenAI, Anthropic, Google, or xAI when using webSearchTool.","If using a router/gateway, use a model string or provider object whose provider resolves to one of the four supported families (e.g. 'openai/gpt-4o').","For unsupported providers, remove webSearchTool and wire a provider-specific search tool manually.","Check the model id/provider string for typos and casing."],"exampleFix":"// before\nnew Agent({ name: 'a', model: 'mistral/mistral-large', tools: { webSearch: webSearchTool } });\n// after\nnew Agent({ name: 'a', model: 'openai/gpt-4o', tools: { webSearch: webSearchTool } });","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['openai', 'anthropic', 'google', 'xai'];\nconst provider = typeof model === 'string' ? model.split('/')[0] : model?.provider;\nif (!SUPPORTED.includes(String(provider))) {\n  throw new Error(`webSearchTool requires one of ${SUPPORTED.join(', ')}; got \"${provider}\"`);\n}","typeGuard":"function isSupportedWebSearchProvider(p: unknown): p is 'openai' | 'anthropic' | 'google' | 'xai' {\n  return p === 'openai' || p === 'anthropic' || p === 'google' || p === 'xai';\n}","tryCatchPattern":"try {\n  agent = new Agent({ model, tools: { webSearch: webSearchTool } });\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'WEB_SEARCH_UNSUPPORTED_PROVIDER') {\n    // fall back to a provider-agnostic search tool or log guidance\n  } else throw e;\n}","preventionTips":["Only combine webSearchTool with OpenAI/Anthropic/Google/xAI models.","Use fully-qualified router model strings like 'openai/gpt-4o'.","Centralize model selection in one config module and assert provider support there."],"tags":["web-search","unsupported-provider","agent-config","user-error"],"backgroundTag":"unsupported-model-provider","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}