mastra-ai/mastra · error · MastraError
MAP_RESULTS_STEP_UNSUPPORTED_MODEL
MAP_RESULTS_STEP_UNSUPPORTED_MODEL
Error message
Tripwire handling requires a v2/v3 model
What it means
In the map-results step of agent streaming workflows, when the model raised a tripwire (guardrail violation), Mastra must re-read the model via capabilities.getModel to handle the tripwire consistently. If the resolved model is not a supported LanguageModelV2/V3 instance, tripwire handling cannot proceed, so this MastraError (USER category) is thrown.
Source
Thrown at packages/core/src/agent/workflows/prepare-stream/map-results-step.ts:127
if (saveQueueManager && memoryData.thread?.id) {
await saveQueueManager.flushMessages(messageList, memoryData.thread.id, memoryConfig);
}
}
return options.onStepFinish?.({ ...props, runId });
},
...(memoryData.tripwire && {
tripwire: memoryData.tripwire,
}),
};
// Check for tripwire and return early if triggered
if (result.tripwire) {
try {
const agentModel = await capabilities.getModel({ requestContext: result.requestContext! });
if (!isSupportedLanguageModel(agentModel)) {
throw new MastraError({
id: 'MAP_RESULTS_STEP_UNSUPPORTED_MODEL',
domain: ErrorDomain.AGENT,
category: ErrorCategory.USER,
text: 'Tripwire handling requires a v2/v3 model',
});
}
const modelOutput = await getModelOutputForTripwire<OUTPUT>({
tripwire: memoryData.tripwire!,
runId,
...createObservabilityContext({ currentSpan: agentSpan }),
options: options,
model: agentModel,
messageList,
});
// End agent span with tripwire information after fallback completes
agentSpan?.end({View on GitHub (pinned to 75dd419e61)
Solutions
- Return a genuine AI SDK LanguageModelV2/V3 model from your getModel capability implementation
- Unwrap custom wrappers and pass the underlying provider model instance
- Upgrade legacy v1 model adapters to v2/v3-compatible provider packages
- Align @mastra/core, ai, and @ai-sdk/* provider versions so the model spec matches
- Remove mocks/stubs that fail isSupportedLanguageModel in production paths
Example fix
// before getModel: async () => myCustomWrapper, // after getModel: async () => myCustomWrapper.underlyingLanguageModelV3, // or the raw @ai-sdk provider model
Defensive patterns
Strategy: validation
Validate before calling
import { isSupportedLanguageModel } from '@mastra/core/agent';
const model = await capabilities.getModel({ requestContext });
if (!isSupportedLanguageModel(model)) {
throw new Error('Agent model must be an AI SDK LanguageModelV2/V3 for tripwire handling');
} Type guard
function isV2OrV3Model(m: unknown): boolean {
return !!m && typeof m === 'object' && 'doStream' in m &&
[2, 3].includes((m as { specificationVersion?: string }).specificationVersion as number) ||
!!m && typeof m === 'object' && 'doStream' in m;
} Try / catch
try {
await workflow.start();
} catch (e) {
if ((e as Error).message.includes('Tripwire handling requires a v2/v3 model')) {
// replace the model adapter with a v2/v3-compatible one and rerun
}
} Prevention
- Return raw provider models (not wrappers) from getModel
- Keep @ai-sdk provider packages on v2/v3 specification versions
- Avoid mocks in production model resolution paths
- Add a startup check that isSupportedLanguageModel(getModel())
When it happens
Trigger: A stream finishes with result.tripwire === true while the agent's resolved model (possibly a custom wrapper, legacy v1 model, or non-standard provider object returned from getModel) fails isSupportedLanguageModel — i.e. not an AI SDK LanguageModelV2/V3.
Common situations: Using a custom model wrapper that doesn't implement the v2/v3 spec; passing a legacy model after upgrading Mastra/AI SDK; dynamic getModel returning a mocked or wrong-typed object in tests; mixing provider packages of mismatched major versions.
Related errors
- Processor tripwire triggered
- Aborted by processor
- Sub-agent ${agent.id} returned a v1 model but does not imple
- Sub-agent ${agent.id} returned a v1 model but does not imple
- Unsupported model version: ${(currentStep.model as { specifi
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/715a248352b6447b.
Report an issue: GitHub.