Highlights
Per-user resource scoping in server auth (secure by default)
Server auth now supports mapUserToResourceId, automatically mapping an authenticated user to a resource ID so memory/threads are isolated per user without custom middleware, and client attempts to inject reserved context keys (mastra__resourceId, mastra__threadId) are stripped.
Experiments + observability are now version-aware end-to-end
Experiments correctly execute the specified agentVersion, and observability gains first-class entityVersionId/parentEntityVersionId/rootEntityVersionId across spans/metrics/scores/logs/feedback (with storage migrations in ClickHouse/DuckDB/Postgres/MongoDB/LibSQL), plus new experiment query filters and experimentId propagation into agent spans and scorer context.
Agent version targeting in AI SDK route handlers
chatRoute(), handleChatStream(), networkRoute(), and handleNetworkStream() now accept agentVersion (and runtime ?versionId= / ?status= overrides) to route traffic to draft/published or specific version IDs (requires the Editor).
Tool calling reliability upgrades: strict mode + better API error recovery
You can enable per-tool strict: true in createTool() for providers that support strict tool calling, and processors can now intercept LLM failures via processAPIError (including a built-in PrefillErrorHandler that retries Anthropic “assistant message prefill” errors automatically).
Browser automation persistence & stability improvements
Agent Browser/Stagehand add lightweight auth persistence via storageState/exportStorageState(), support persistent sessions via profile and custom Chrome via executablePath, and improve cleanup (stale lock files/orphaned Chrome processes) for more reliable runs.
Breaking Changes
@mastra/voice-sarvam@1.0.0drops deprecated Sarvam models (bulbul:v1,saarika:v1/v2/flash), defaults shift tobulbul:v3+ speakershubh, and the TTS request payload changes frominputs[]totext.
Changelog
@mastra/core@1.25.0
Minor Changes
-
feat(server): Add
mapUserToResourceIdcallback to auth config for automatic resource ID scoping (#13954)Auth configs now accept a
mapUserToResourceIdcallback that maps the authenticated user to a resource ID after successful authentication. This enables per-user memory and thread isolation without requiring custom middleware or adapter subclassing.const mastra = new Mastra({ server: { auth: { authenticateToken: async token => verifyToken(token), mapUserToResourceId: user => user.id, }, }, });
The callback is called in
coreAuthMiddlewareafter the user is authenticated and set on the request context. The returned value is set asMASTRA_RESOURCE_ID_KEY, which takes precedence over client-provided values for security. Works across all server adapters (Hono, Express, Next.js, etc.). -
Added
processAPIErrorhook to the Processor interface for intercepting LLM API call failures before they surface as errors. New built-inPrefillErrorHandlerautomatically recovers from Anthropic "assistant message prefill" errors by appending a<system-reminder>continue</system-reminder>user message and retrying once. (#14435) -
Experiments now run the correct agent version (#15317)
When an experiment specifies
agentVersion, the experiment pipeline now resolves and executes against that specific version instead of ignoring it. Previously, the version was stored as metadata but the agent always ran with its current default configuration.entityVersionIdis now a first-class observability dimensionNew
entityVersionId,parentEntityVersionId, androotEntityVersionIdfields are available on all observability records (spans, metrics, scores, feedback, logs). This enables filtering and grouping OLAP queries by version at any level of the span tree.rootEntityVersionIdis particularly useful for aggregating all signals within a versioned agent's trace. This replaces the previousresolvedVersionIdattribute which was buried in span attributes and unfilterable.experimentIdpropagated to agent spansAgent spans created during experiment execution now carry the
experimentId, enabling trace-to-experiment cross-referencing.Scorer correlation context
Scorers running in the experiment pipeline now receive full
targetCorrelationContext(includingexperimentId), so scores emitted via observability carry experiment context.New experiment query filters
listExperimentsnow supports filtering bytargetType,targetId,agentVersion, andstatus.listExperimentResultsnow supports filtering bytraceIdandstatus. -
Added
profileandexecutablePathoptions to browser config for persistent sessions and custom browser support. Automatically cleans up stale Chrome lock files on browser close. (#15194) -
Added (#15313)
Added per-tool strict mode for providers that support strict tool calling. You can now setstrict: trueoncreateTool()and Mastra will forward it when preparing tool definitions.const weatherTool = createTool({ id: 'weather', description: 'Get weather for a city', strict: true, inputSchema: z.object({ city: z.string() }), execute: async ({ city }) => ({ city }), });
Patch Changes
-
Update provider registry and model documentation with latest models and providers (
582644c) -
Fixed
mastra_workspace_list_filessilently returning no files when agents passed an emptypattern(e.g.pattern: []orpattern: ''). Empty and whitespace-only patterns are now treated as "no filter" and return the full listing instead of a dirs-only view or a picomatch error. (#15360)Fixed harness tool approval, decline, and resume handlers hardcoding
requireToolApproval: true. They now follow the harnessyolostate likesendMessagealready does, so resumed tool calls in yolo mode no longer get unexpectedly re-gated on approval. -
Update references to "Mastra Cloud" to "Mastra platform" (#15297)
-
Fixed symlinked skill paths so workspace skills resolve consistently and allowed path checks work through both symlink and real paths. (#15228)
-
AgentBrowser with default thread scope now initializes correctly. Previously, calling launch() followed by getPage() would throw "Browser not launched" when no explicit thread ID was provided. (#15285)
-
fix: ensure listVectorStores always returns a string id (#15239)
-
Improved
structuredOutput.modelerror messages to surface upstream structuring failures, including plain-object errors, instead of a generic internal agent error. (#15226) -
Agent instances can now create lightweight clones that preserve all configuration, so version overrides and tools are isolated without mutating the shared runtime agent. (#15314)
-
Fixed
structuredOutput.modelcustom gateway resolution by registering the internal structuring agent with the parent Mastra instance. (#15230) -
Fixed OpenAI reasoning summary streaming so reasoning summary text is preserved when multiple summaries overlap or finish out of order. (#15225)
-
Upgraded model router providers to AI SDK v3 spec: OpenAI, Anthropic, Google, xAI, Groq, and Mistral now use the latest v6 SDK packages. Providers built on
openai-compatible(Cerebras, DeepInfra, DeepSeek, Perplexity, TogetherAI) remain on v2 spec until their base package is updated. All provider packages (both v5 and v6) bumped to their latest stable patch versions. (#15358)Fixed 'item missing its reasoning part' error for OpenAI reasoning models (gpt-5-mini, gpt-5.2). The v5 SDK couldn't serialize reasoning items for OpenAI's Responses API, so Mastra stripped them from prompts — but this caused errors in multi-turn conversations with memory enabled. With v3 providers, reasoning items are serialized natively and the stripping workaround has been removed.
-
Fixed gateway model detection to use duck typing instead of instanceof check, preventing potential failures from cross-package module resolution issues. Propagates
gatewayIdthrough the AISDKV5LanguageModel wrapper so duck-type detection works even when models are re-wrapped. (#15168) -
Fixed Channels not working on Vercel serverless (and other serverless platforms). Webhook handlers now await initialization on cold starts instead of immediately returning 503, and pass the platform's
waitUntilto the Chat SDK so agent processing survives after the HTTP response is sent. See #15300. (#15335) -
fix(core): Restore AI SDK v6 provider option typings for vector embeddings (#15306)
The vendored AI SDK v6 declaration build now re-exports
ProviderOptionsafter type bundling renames it toProviderOptions_2. This fixesTS2724errors in@mastra/corewhen vector embeddings import AI SDK v6 provider option types.
@mastra/agent-browser@0.2.0
Minor Changes
- Added
storageStateoption andexportStorageState()method for lightweight auth persistence (cookies and localStorage). Also kills orphaned Chrome child processes on close to prevent zombies. (#15194)
Patch Changes
- AgentBrowser with default thread scope now initializes correctly. Previously, calling launch() followed by getPage() would throw "Browser not launched" when no explicit thread ID was provided. (#15285)
@mastra/ai-sdk@1.4.0
Minor Changes
-
Added structured output streaming to the AI SDK UI stream. When an agent produces structured output, the final object is now emitted as a
data-structured-outputdata part in the UI message stream, making it available to frontends via AI SDK UI's custom data handling. (#15237) -
Added agent versioning support to chat and network route handlers. You can now pass
agentVersiontochatRoute(),handleChatStream(),networkRoute(), andhandleNetworkStream()to target a specific agent version by ID or status (draft/published). Route handlers also accept?versionId=<id>or?status=draft|publishedquery parameters at request time, which take precedence over static configuration. Requires the Editor to be configured. (#15296)// Static version on route config chatRoute({ path: '/chat', agent: 'weatherAgent', agentVersion: { status: 'published' }, }); // Programmatic version on handler const stream = await handleChatStream({ mastra, agentId: 'weatherAgent', agentVersion: { versionId: 'ver_abc123' }, params, });
Patch Changes
- Fixed reasoning streams so reasoning UI parts are only emitted when reasoning content is included. (#15207)
@mastra/clickhouse@1.4.1
Patch Changes
- Added
entityVersionId,parentEntityVersionId, androotEntityVersionIdcolumns to observability storage tables (spans, metrics, scores, feedback, logs) for filtering and grouping traces by entity version. Added ALTER TABLE migrations for existing databases. AddedtargetType,targetId,agentVersion, andstatusfilters tolistExperiments, andtraceIdandstatusfilters tolistExperimentResults. (#15317)
@mastra/duckdb@1.1.2
Patch Changes
- Added
entityVersionId,parentEntityVersionId, androotEntityVersionIdcolumns to observability storage tables (spans, metrics, scores, feedback, logs) for filtering and grouping traces by entity version. Added ALTER TABLE migrations for existing databases. AddedtargetType,targetId,agentVersion, andstatusfilters tolistExperiments, andtraceIdandstatusfilters tolistExperimentResults. (#15317)
@mastra/editor@0.7.16
Patch Changes
- Resolving stored agent versions no longer mutates the shared singleton agent instance. Instruction and tool overrides are now applied to an isolated clone, making concurrent version resolution safe and preventing overrides from leaking onto the global agent. (#15314)
@mastra/libsql@1.8.1
Patch Changes
-
Fixed "column does not exist" errors when using experiment review features on databases created before the review pipeline was introduced. Startup now automatically migrates older experiment tables to the latest schema. (#15304)
-
Added
entityVersionId,parentEntityVersionId, androotEntityVersionIdcolumns to observability storage tables (spans, metrics, scores, feedback, logs) for filtering and grouping traces by entity version. Added ALTER TABLE migrations for existing databases. AddedtargetType,targetId,agentVersion, andstatusfilters tolistExperiments, andtraceIdandstatusfilters tolistExperimentResults. (#15317)
@mastra/mcp@1.5.0
Minor Changes
- Added
requireToolApprovaloption to MCP server configuration for requiring human approval before tool execution. Supports both boolean (all tools) and function (dynamic per-tool logic). (#15315)
Patch Changes
- Preserve forwarded MCP client elicitation capabilities so client-supported URL and form elicitations work correctly. (#15233)
@mastra/memory@1.15.1
Patch Changes
- Fixed gateway model detection to use duck typing instead of instanceof check, preventing potential failures from cross-package module resolution issues. Propagates
gatewayIdthrough the AISDKV5LanguageModel wrapper so duck-type detection works even when models are re-wrapped. (#15168)
@mastra/mongodb@1.7.1
Patch Changes
- Added
entityVersionId,parentEntityVersionId, androotEntityVersionIdcolumns to observability storage tables (spans, metrics, scores, feedback, logs) for filtering and grouping traces by entity version. Added ALTER TABLE migrations for existing databases. AddedtargetType,targetId,agentVersion, andstatusfilters tolistExperiments, andtraceIdandstatusfilters tolistExperimentResults. (#15317)
@mastra/observability@1.9.1
Patch Changes
-
Fixed double-counting of Anthropic cache tokens in usage metrics (#15316)
-
Cost estimates now use the latest model pricing rates for more accurate calculations (#15362)
-
Update references to "Mastra Cloud" to "Mastra platform" (#15297)
-
Reduced observability overhead for
MODEL_STEPspans by storing a lightweight message preview of request bodies. (#15249)This keeps span previews readable and avoids pulling large payloads into exporter input.
-
Fixed cost lookup for models with date suffixes. Providers like OpenAI often return model names with date suffixes (e.g.,
gpt-5.4-mini-2026-03-17) that don't exactly match pricing data entries. The lookup now tries multiple variants including stripping date suffixes and converting dots to dashes. (#15349) -
Added
entityVersionId,parentEntityVersionId, androotEntityVersionIdto span correlation context, enabling version information to propagate to scores, metrics, logs, and feedback emitted during traced execution. (#15317) -
Fixed stack traces for errors reported to Sentry. Exceptions now point to the code that threw the error instead of
SentryExporter.handleSpanEndedinside the exporter, so issues in Sentry are actually debuggable. (#15343)This was caused by two issues, both fixed:
@mastra/sentrypassed the error message as a string toSentry.captureException, which made Sentry synthesize a stack trace from the exporter's call site. It now passes anErrorinstance with the captured stack attached.@mastra/observabilitystored the wrappingMastraError's stack on the span, hiding the original error's location. When theMastraErrorhas a cause, the cause's stack is now preserved.
Fixes #15337.
@mastra/pg@1.9.1
Patch Changes
-
Fixed vector similarity queries to leverage HNSW and IVFFlat indexes. When querying without filters on an HNSW or IVFFlat-indexed table, ORDER BY and LIMIT are now placed inside the CTE so PostgreSQL can use the index for faster approximate nearest neighbor searches instead of scanning all rows. (#14574)
-
Fixed
batchInsertandbatchUpdatein@mastra/pgto run on a single Postgres transaction connection. (#15312)This prevents pooled
BEGIN/COMMIT/ROLLBACKcalls from landing on different connections and leaving idle transactions open during batch writes. -
Fixed "column does not exist" errors when using experiment review features on databases created before the review pipeline was introduced. Startup now automatically migrates older experiment tables to the latest schema. (#15304)
-
Fixed vector operations failing when pgvector extension is installed in a custom schema. The search_path is now set before index creation and vector similarity queries, ensuring operator classes (e.g. vector_cosine_ops) and distance operators (e.g. <=>) resolve correctly regardless of where the extension is installed. Previously, only table creation set the search_path, causing CREATE INDEX and query operations to fail with unresolvable operator errors. (#14526)
-
Added
entityVersionId,parentEntityVersionId, androotEntityVersionIdcolumns to observability storage tables (spans, metrics, scores, feedback, logs) for filtering and grouping traces by entity version. Added ALTER TABLE migrations for existing databases. AddedtargetType,targetId,agentVersion, andstatusfilters tolistExperiments, andtraceIdandstatusfilters tolistExperimentResults. (#15317)
@mastra/playground-ui@22.1.2
Patch Changes
-
Added
PageLayoutandPageHeadercompound components for consistent page structure across Mastra Studio, plus aNoDataPageLayouthelper for 401/403/empty/error states. (#15243)List components (
AgentsList,WorkflowsList,ToolsList,ProcessorsList,McpServersList,PromptsList,LogsList,ObservabilityTracesList) no longer handle errors or empty states internally — handle those at the page level. If you consume these components directly, move error/empty-state rendering to the parent. -
Fix dataset detail tab badges to use total item and experiment counts instead of currently loaded rows. (#14994)
-
Added
EntityList.Paginationsub-component for server-side pagination ofEntityListviews. Mirrors the existingItemList.PaginationAPI. (#15353) -
Added ValueLink, ValueWithTooltip, and ValueWithCopyBtn variants to DataKeysAndValues component (#15208)
-
Refresh Studio Evaluation pages with an updated UI and flattened top-level URLs (
/scorers,/datasets,/experiments;/evaluationremains as the overview).@mastra/playground-uiremovesEvaluationDashboardand allEvaluation*-prefixed list components, constants, and hooks — use the per-domain replacements (e.g.ScorersList) instead. (#15258) -
Fixed DataList to only take as much height as its content needs instead of always stretching to fill available space (#15291)
@mastra/posthog@1.0.17
Patch Changes
- Fixed generation traces producing stringified JSON in messages instead of structured content. Input messages wrapped as
{messages: [...]}and output objects withtextare now properly extracted and formatted. (#15203)
@mastra/schema-compat@1.2.8
Patch Changes
-
--- (#14624)
@mastra/schema-compat: patch
Improved provider schema compatibility for structured outputs and tool calls.
Fixed validation for optional, nullable, and defaulted fields, and for ISO date strings returned for date fields.
@mastra/sentry@1.0.16
Patch Changes
-
Fixed stack traces for errors reported to Sentry. Exceptions now point to the code that threw the error instead of
SentryExporter.handleSpanEndedinside the exporter, so issues in Sentry are actually debuggable. (#15343)This was caused by two issues, both fixed:
@mastra/sentrypassed the error message as a string toSentry.captureException, which made Sentry synthesize a stack trace from the exporter's call site. It now passes anErrorinstance with the captured stack attached.@mastra/observabilitystored the wrappingMastraError's stack on the span, hiding the original error's location. When theMastraErrorhas a cause, the cause's stack is now preserved.
Fixes #15337.
@mastra/server@1.25.0
Minor Changes
-
feat(server): Add
mapUserToResourceIdcallback to auth config for automatic resource ID scoping (#13954)Auth configs now accept a
mapUserToResourceIdcallback that maps the authenticated user to a resource ID after successful authentication. This enables per-user memory and thread isolation without requiring custom middleware or adapter subclassing.const mastra = new Mastra({ server: { auth: { authenticateToken: async token => verifyToken(token), mapUserToResourceId: user => user.id, }, }, });
The callback is called in
coreAuthMiddlewareafter the user is authenticated and set on the request context. The returned value is set asMASTRA_RESOURCE_ID_KEY, which takes precedence over client-provided values for security. Works across all server adapters (Hono, Express, Next.js, etc.).
Patch Changes
-
fix(server): Strip reserved context keys from client-provided requestContext (#13954)
Clients could inject
mastra__resourceIdormastra__threadIdvia the request body or query params to impersonate other users' memory/thread access. Reserved keys are now filtered out during request context creation inmergeRequestContext, so only server-side code (auth callbacks, middleware) can set them.
@mastra/stagehand@0.2.0
Minor Changes
- Added automatic cleanup on browser close: patches
exit_typeto prevent restore dialogs, kills orphaned Chrome child processes, and uses CDP events for reliable disconnect detection in both shared and thread scope. (#15194)
Patch Changes
@mastra/voice-sarvam@1.0.0
Major Changes
-
Added support for Sarvam's current TTS and STT models. Previously the package only supported the now-deprecated bulbul:v1 and saarika:v1/v2/flash models, which Sarvam has retired. (#15204)
What's new:
- TTS models:
bulbul:v2,bulbul:v3(default), andbulbul:v3-beta.bulbul:v3andbulbul:v3-betasupport 39 speakers;bulbul:v2supports 7 speakers. - STT models:
saarika:v2.5(default) andsaaras:v3.saaras:v3is a multi-mode model that supportstranscribe,translate,verbatim,translit, andcodemixvia a newmodeoption. - New bulbul:v3 parameters:
temperature,dict_id,output_audio_codec. - Expanded
speech_sample_rateoptions: 8000, 16000, 22050, 24000, 32000, 44100, 48000.
Breaking changes:
- Removed the deprecated
bulbul:v1TTS model and its speakers (meera,pavithra,maitreyi,arvind,amol,amartya,diya,neel,misha,vian,arjun,maya). Sarvam has retired the underlying API. - Removed the deprecated
saarika:v1,saarika:v2, andsaarika:flashSTT models. - The default TTS model is now
bulbul:v3and the default speaker isshubh. Speakers are not interchangeable between bulbul versions — each has its own catalog. - The TTS request body now sends
text(single string) instead ofinputs(array), matching Sarvam's current API.
Migration:
Before:
const voice = new SarvamVoice({ speechModel: { model: 'bulbul:v1', language: 'en-IN' }, speaker: 'meera', listeningModel: { model: 'saarika:v2' }, });
After:
const voice = new SarvamVoice({ speechModel: { model: 'bulbul:v3', language: 'en-IN' }, speaker: 'shubh', listeningModel: { model: 'saarika:v2.5' }, }); // Or use saaras:v3 for speech translation: await voice.listen(audio, { model: 'saaras:v3', mode: 'translate' });
Resolves #15188.
- TTS models:
Patch Changes
Other updated packages
The following packages were updated with dependency changes only:
- @mastra/agent-builder@1.0.26
- @mastra/arize@1.0.17
- @mastra/arthur@0.2.3
- @mastra/braintrust@1.0.17
- @mastra/client-js@1.13.4
- @mastra/datadog@1.0.17
- @mastra/deployer@1.25.0
- @mastra/deployer-cloud@1.25.0
- @mastra/deployer-cloudflare@1.1.23
- @mastra/deployer-netlify@1.0.27
- @mastra/deployer-vercel@1.1.17
- @mastra/express@1.3.9
- @mastra/fastify@1.3.9
- @mastra/hono@1.4.4
- @mastra/koa@1.4.9
- @mastra/laminar@1.0.16
- @mastra/langfuse@1.1.3
- @mastra/langsmith@1.1.14
- @mastra/longmemeval@1.0.28
- @mastra/mcp-docs-server@1.1.25
- @mastra/opencode@0.0.25
- @mastra/otel-bridge@1.0.16
- @mastra/otel-exporter@1.0.16
- @mastra/react@0.2.26