mastra-ai/mastra · error · MastraError
WEB_SEARCH_UNSUPPORTED_PROVIDER
WEB_SEARCH_UNSUPPORTED_PROVIDER
Error message
The built-in webSearchTool supports OpenAI, Anthropic, Google, and xAI models. Could not infer a supported provider from "${provider}". What it means
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.
Source
Thrown at packages/core/src/tools/builtin/web-search.ts:41
tool === webSearchTool ||
(typeof tool === 'object' && tool !== null && (tool as WebSearchToolPlaceholder)[WEB_SEARCH_TOOL_MARKER] === true)
);
}
export function normalizeWebSearchProvider(providerOrModel: unknown): WebSearchProvider {
const provider = getProviderString(providerOrModel);
const supportedProviders = new Set<WebSearchProvider>(['openai', 'anthropic', 'google', 'xai']);
if (supportedProviders.has(provider as WebSearchProvider)) {
return provider as WebSearchProvider;
}
const routerProvider = getRouterProvider(provider);
if (supportedProviders.has(routerProvider as WebSearchProvider)) {
return routerProvider as WebSearchProvider;
}
throw new MastraError({
id: 'WEB_SEARCH_UNSUPPORTED_PROVIDER',
domain: ErrorDomain.AGENT,
category: ErrorCategory.USER,
details: {
provider,
},
text: `The built-in webSearchTool supports OpenAI, Anthropic, Google, and xAI models. Could not infer a supported provider from "${provider}".`,
});
}
export function createWebSearchProviderTool(provider: WebSearchProvider): ProviderDefinedTool {
const tool = getWebSearchProviderTool(provider);
return {
type: 'provider-defined',
id: tool.id,
name: tool.name,
args: {},
} as ProviderDefinedTool;View on GitHub (pinned to 75dd419e61)
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.
Example fix
// before
new Agent({ name: 'a', model: 'mistral/mistral-large', tools: { webSearch: webSearchTool } });
// after
new Agent({ name: 'a', model: 'openai/gpt-4o', tools: { webSearch: webSearchTool } }); Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED = ['openai', 'anthropic', 'google', 'xai'];
const provider = typeof model === 'string' ? model.split('/')[0] : model?.provider;
if (!SUPPORTED.includes(String(provider))) {
throw new Error(`webSearchTool requires one of ${SUPPORTED.join(', ')}; got "${provider}"`);
} Type guard
function isSupportedWebSearchProvider(p: unknown): p is 'openai' | 'anthropic' | 'google' | 'xai' {
return p === 'openai' || p === 'anthropic' || p === 'google' || p === 'xai';
} Try / catch
try {
agent = new Agent({ model, tools: { webSearch: webSearchTool } });
} catch (e) {
if (e instanceof MastraError && e.id === 'WEB_SEARCH_UNSUPPORTED_PROVIDER') {
// fall back to a provider-agnostic search tool or log guidance
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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'.
Related errors
- Unsupported browser provider: ${provider}
- Parallel ${operation} returned no output
- ${output.message}
- EXPERIMENT_HAS_NO_TARGET
- EXPERIMENT_ALREADY_FINALIZED
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/535ee10f4f1d4c80.
Report an issue: GitHub.