@mastra/mcp-docs-server 1.0.0-beta.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40internal%2Fchangeset-cli.md +1 -13
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +1 -5
- package/.docs/organized/changelogs/%40internal%2Fplayground.md +40 -0
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +1 -53
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +287 -287
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +315 -315
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +53 -53
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +38 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +66 -66
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +522 -212
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +658 -196
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +439 -234
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +450 -211
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +208 -0
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +448 -22
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +3341 -271
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +60 -60
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +289 -289
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +90 -90
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +74 -74
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +247 -220
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +70 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +403 -225
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +72 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +145 -145
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +54 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +456 -226
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +604 -208
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +71 -71
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +247 -247
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +285 -285
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +354 -156
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +545 -212
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +481 -202
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +194 -194
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +759 -213
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +198 -198
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +636 -229
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +163 -163
- package/.docs/organized/changelogs/%40mastra%2Frag.md +310 -310
- package/.docs/organized/changelogs/%40mastra%2Freact.md +328 -230
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +64 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +160 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +829 -218
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +479 -232
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +53 -53
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +110 -110
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +15 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +98 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +54 -54
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +46 -46
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +93 -93
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +45 -45
- package/.docs/organized/changelogs/create-mastra.md +227 -227
- package/.docs/organized/changelogs/mastra.md +277 -277
- package/.docs/organized/code-examples/a2a.md +2 -2
- package/.docs/organized/code-examples/agent-v6.md +221 -0
- package/.docs/organized/code-examples/agui.md +4 -4
- package/.docs/organized/code-examples/ai-elements.md +3 -3
- package/.docs/organized/code-examples/ai-sdk-useChat.md +2 -2
- package/.docs/organized/code-examples/ai-sdk-v5.md +3 -3
- package/.docs/organized/code-examples/assistant-ui.md +5 -5
- package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +2 -2
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +3 -3
- package/.docs/organized/code-examples/client-side-tools.md +4 -4
- package/.docs/organized/code-examples/crypto-chatbot.md +5 -5
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +1 -1
- package/.docs/organized/code-examples/fireworks-r1.md +2 -2
- package/.docs/organized/code-examples/heads-up-game.md +7 -7
- package/.docs/organized/code-examples/inngest.md +1075 -0
- package/.docs/organized/code-examples/mcp-configuration.md +1 -1
- package/.docs/organized/code-examples/mcp-server-adapters.md +3 -4
- package/.docs/organized/code-examples/memory-per-resource-example.md +3 -3
- package/.docs/organized/code-examples/memory-todo-agent.md +1 -1
- package/.docs/organized/code-examples/memory-with-context.md +1 -1
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +3 -3
- package/.docs/organized/code-examples/processors-with-ai-sdk.md +14 -0
- package/.docs/organized/code-examples/quick-start.md +1 -5
- package/.docs/organized/code-examples/server-app-access.md +3 -3
- package/.docs/organized/code-examples/server-express-adapter.md +1 -1
- package/.docs/organized/code-examples/server-fastify-adapter.md +83 -0
- package/.docs/organized/code-examples/server-hono-adapter.md +3 -3
- package/.docs/organized/code-examples/server-koa-adapter.md +94 -0
- package/.docs/organized/code-examples/stock-price-tool.md +21 -2
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +1 -1
- package/.docs/raw/agents/adding-voice.mdx +24 -6
- package/.docs/raw/agents/agent-approval.mdx +209 -12
- package/.docs/raw/agents/agent-memory.mdx +36 -32
- package/.docs/raw/agents/guardrails.mdx +105 -56
- package/.docs/raw/agents/network-approval.mdx +281 -0
- package/.docs/raw/agents/networks.mdx +69 -13
- package/.docs/raw/agents/overview.mdx +43 -25
- package/.docs/raw/agents/processors.mdx +234 -17
- package/.docs/raw/agents/structured-output.mdx +78 -8
- package/.docs/raw/agents/using-tools.mdx +67 -6
- package/.docs/raw/course/01-first-agent/07-creating-your-agent.md +1 -2
- package/.docs/raw/course/01-first-agent/12-connecting-tool-to-agent.md +1 -1
- package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +1 -2
- package/.docs/raw/course/02-agent-tools-mcp/05-updating-your-agent.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/10-updating-agent-instructions-zapier.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/16-updating-agent-instructions-github.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/21-updating-agent-instructions-hackernews.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/27-updating-agent-instructions-filesystem.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +3 -3
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -2
- package/.docs/raw/course/03-agent-memory/07-understanding-memory-threads.md +35 -0
- package/.docs/raw/course/03-agent-memory/08-configuring-conversation-history.md +1 -2
- package/.docs/raw/course/03-agent-memory/13-vector-store-configuration.md +1 -1
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +4 -5
- package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -1
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +3 -4
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +3 -4
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +3 -4
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +3 -4
- package/.docs/raw/course/04-workflows/11-creating-an-ai-agent.md +2 -3
- package/.docs/raw/deployment/cloud-providers.mdx +22 -0
- package/.docs/raw/deployment/mastra-server.mdx +140 -0
- package/.docs/raw/deployment/monorepo.mdx +106 -42
- package/.docs/raw/deployment/overview.mdx +35 -48
- package/.docs/raw/deployment/web-framework.mdx +17 -19
- package/.docs/raw/deployment/workflow-runners.mdx +16 -0
- package/.docs/raw/evals/built-in-scorers.mdx +2 -0
- package/.docs/raw/evals/custom-scorers.mdx +60 -12
- package/.docs/raw/evals/overview.mdx +6 -6
- package/.docs/raw/evals/running-in-ci.mdx +4 -2
- package/.docs/raw/getting-started/manual-install.mdx +20 -20
- package/.docs/raw/getting-started/mcp-docs-server.mdx +59 -2
- package/.docs/raw/getting-started/project-structure.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +17 -1
- package/.docs/raw/getting-started/studio.mdx +10 -37
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +151 -0
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +1034 -80
- package/.docs/raw/guides/build-your-ui/assistant-ui.mdx +8 -8
- package/.docs/raw/guides/build-your-ui/copilotkit.mdx +32 -11
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/amazon-ec2.mdx +9 -9
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/aws-lambda.mdx +13 -16
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/azure-app-services.mdx +5 -7
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/cloudflare-deployer.mdx +8 -5
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/digital-ocean.mdx +18 -23
- package/.docs/raw/guides/deployment/index.mdx +32 -0
- package/.docs/raw/guides/deployment/inngest.mdx +673 -0
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/netlify-deployer.mdx +7 -3
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/vercel-deployer.mdx +8 -5
- package/.docs/raw/guides/getting-started/astro.mdx +292 -451
- package/.docs/raw/guides/getting-started/express.mdx +72 -153
- package/.docs/raw/guides/getting-started/hono.mdx +227 -0
- package/.docs/raw/guides/getting-started/next-js.mdx +173 -61
- package/.docs/raw/guides/getting-started/nuxt.mdx +505 -0
- package/.docs/raw/guides/getting-started/quickstart.mdx +5 -5
- package/.docs/raw/guides/getting-started/sveltekit.mdx +238 -409
- package/.docs/raw/guides/getting-started/vite-react.mdx +317 -147
- package/.docs/raw/guides/guide/ai-recruiter.mdx +10 -10
- package/.docs/raw/guides/guide/chef-michel.mdx +9 -11
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +15 -15
- package/.docs/raw/guides/guide/research-assistant.mdx +20 -20
- package/.docs/raw/guides/guide/stock-agent.mdx +5 -5
- package/.docs/raw/guides/guide/web-search.mdx +38 -38
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +7 -7
- package/.docs/raw/guides/index.mdx +0 -1
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +2 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +105 -4
- package/.docs/raw/guides/migrations/upgrade-to-v1/cli.mdx +15 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +170 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/deployment.mdx +42 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +0 -35
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +40 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +17 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +11 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/rag.mdx +47 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +271 -25
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +3 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/tracing.mdx +72 -17
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +46 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +50 -7
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +21 -23
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/mastra-cloud/deployment.mdx +86 -0
- package/.docs/raw/mastra-cloud/observability.mdx +43 -0
- package/.docs/raw/mastra-cloud/overview.mdx +31 -0
- package/.docs/raw/mastra-cloud/setup.mdx +64 -0
- package/.docs/raw/mastra-cloud/studio.mdx +35 -0
- package/.docs/raw/mcp/overview.mdx +60 -25
- package/.docs/raw/mcp/publishing-mcp-server.mdx +7 -4
- package/.docs/raw/memory/memory-processors.mdx +17 -12
- package/.docs/raw/memory/message-history.mdx +72 -0
- package/.docs/raw/memory/overview.mdx +38 -76
- package/.docs/raw/memory/semantic-recall.mdx +65 -52
- package/.docs/raw/memory/storage.mdx +248 -0
- package/.docs/raw/memory/working-memory.mdx +24 -13
- package/.docs/raw/observability/logging.mdx +16 -15
- package/.docs/raw/observability/overview.mdx +27 -7
- package/.docs/raw/observability/tracing/bridges/otel.mdx +7 -4
- package/.docs/raw/observability/tracing/exporters/arize.mdx +61 -24
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +32 -22
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +24 -5
- package/.docs/raw/observability/tracing/exporters/datadog.mdx +175 -0
- package/.docs/raw/observability/tracing/exporters/default.mdx +28 -7
- package/.docs/raw/observability/tracing/exporters/laminar.mdx +89 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +31 -22
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +33 -3
- package/.docs/raw/observability/tracing/exporters/otel.mdx +194 -22
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +32 -22
- package/.docs/raw/observability/tracing/exporters/sentry.mdx +198 -0
- package/.docs/raw/observability/tracing/overview.mdx +388 -108
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +27 -7
- package/.docs/raw/rag/chunking-and-embedding.mdx +22 -33
- package/.docs/raw/rag/graph-rag.mdx +223 -0
- package/.docs/raw/rag/overview.mdx +6 -3
- package/.docs/raw/rag/retrieval.mdx +53 -57
- package/.docs/raw/rag/vector-databases.mdx +55 -31
- package/.docs/raw/reference/agents/agent.mdx +17 -14
- package/.docs/raw/reference/agents/generate.mdx +172 -44
- package/.docs/raw/reference/agents/generateLegacy.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDescription.mdx +3 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +5 -3
- package/.docs/raw/reference/agents/getLLM.mdx +5 -3
- package/.docs/raw/reference/agents/getMemory.mdx +5 -3
- package/.docs/raw/reference/agents/getModel.mdx +5 -3
- package/.docs/raw/reference/agents/getTools.mdx +4 -2
- package/.docs/raw/reference/agents/getVoice.mdx +4 -2
- package/.docs/raw/reference/agents/listAgents.mdx +4 -2
- package/.docs/raw/reference/agents/listScorers.mdx +5 -3
- package/.docs/raw/reference/agents/listTools.mdx +4 -2
- package/.docs/raw/reference/agents/listWorkflows.mdx +4 -2
- package/.docs/raw/reference/agents/network.mdx +113 -1
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +6 -3
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +4 -2
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +4 -2
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +5 -3
- package/.docs/raw/reference/ai-sdk/network-route.mdx +6 -3
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +10 -6
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +130 -0
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +110 -0
- package/.docs/raw/reference/ai-sdk/with-mastra.mdx +122 -0
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +7 -4
- package/.docs/raw/reference/auth/auth0.mdx +5 -3
- package/.docs/raw/reference/auth/clerk.mdx +5 -3
- package/.docs/raw/reference/auth/firebase.mdx +6 -5
- package/.docs/raw/reference/auth/jwt.mdx +5 -3
- package/.docs/raw/reference/auth/supabase.mdx +5 -3
- package/.docs/raw/reference/auth/workos.mdx +5 -3
- package/.docs/raw/reference/cli/create-mastra.mdx +12 -10
- package/.docs/raw/reference/cli/mastra.mdx +63 -15
- package/.docs/raw/reference/client-js/agents.mdx +311 -85
- package/.docs/raw/reference/client-js/error-handling.mdx +3 -3
- package/.docs/raw/reference/client-js/logs.mdx +2 -0
- package/.docs/raw/reference/client-js/mastra-client.mdx +6 -4
- package/.docs/raw/reference/client-js/memory.mdx +47 -2
- package/.docs/raw/reference/client-js/observability.mdx +2 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +2 -0
- package/.docs/raw/reference/client-js/tools.mdx +2 -0
- package/.docs/raw/reference/client-js/vectors.mdx +2 -0
- package/.docs/raw/reference/client-js/workflows.mdx +47 -3
- package/.docs/raw/reference/configuration.mdx +761 -0
- package/.docs/raw/reference/core/addGateway.mdx +2 -0
- package/.docs/raw/reference/core/getAgent.mdx +3 -1
- package/.docs/raw/reference/core/getAgentById.mdx +3 -1
- package/.docs/raw/reference/core/getDeployer.mdx +3 -1
- package/.docs/raw/reference/core/getGateway.mdx +2 -0
- package/.docs/raw/reference/core/getGatewayById.mdx +2 -0
- package/.docs/raw/reference/core/getLogger.mdx +3 -1
- package/.docs/raw/reference/core/getMCPServer.mdx +3 -1
- package/.docs/raw/reference/core/getMCPServerById.mdx +3 -1
- package/.docs/raw/reference/core/getMemory.mdx +77 -0
- package/.docs/raw/reference/core/getScorer.mdx +2 -0
- package/.docs/raw/reference/core/getScorerById.mdx +2 -0
- package/.docs/raw/reference/core/getServer.mdx +6 -4
- package/.docs/raw/reference/core/getStorage.mdx +5 -3
- package/.docs/raw/reference/core/getStoredAgentById.mdx +185 -0
- package/.docs/raw/reference/core/getTelemetry.mdx +3 -1
- package/.docs/raw/reference/core/getVector.mdx +3 -1
- package/.docs/raw/reference/core/getWorkflow.mdx +3 -1
- package/.docs/raw/reference/core/listAgents.mdx +3 -1
- package/.docs/raw/reference/core/listGateways.mdx +2 -0
- package/.docs/raw/reference/core/listLogs.mdx +3 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +3 -1
- package/.docs/raw/reference/core/listMCPServers.mdx +3 -1
- package/.docs/raw/reference/core/listMemory.mdx +74 -0
- package/.docs/raw/reference/core/listScorers.mdx +2 -0
- package/.docs/raw/reference/core/listStoredAgents.mdx +153 -0
- package/.docs/raw/reference/core/listVectors.mdx +3 -1
- package/.docs/raw/reference/core/listWorkflows.mdx +3 -1
- package/.docs/raw/reference/core/mastra-class.mdx +35 -20
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +2 -0
- package/.docs/raw/reference/core/setLogger.mdx +3 -1
- package/.docs/raw/reference/core/setStorage.mdx +6 -4
- package/.docs/raw/reference/deployer/cloudflare.mdx +22 -53
- package/.docs/raw/reference/deployer/deployer.mdx +2 -1
- package/.docs/raw/reference/deployer/netlify.mdx +4 -1
- package/.docs/raw/reference/deployer/vercel.mdx +5 -4
- package/.docs/raw/reference/evals/answer-relevancy.mdx +4 -1
- package/.docs/raw/reference/evals/answer-similarity.mdx +4 -1
- package/.docs/raw/reference/evals/bias.mdx +4 -1
- package/.docs/raw/reference/evals/completeness.mdx +4 -1
- package/.docs/raw/reference/evals/content-similarity.mdx +4 -1
- package/.docs/raw/reference/evals/context-precision.mdx +4 -1
- package/.docs/raw/reference/evals/context-relevance.mdx +2 -0
- package/.docs/raw/reference/evals/create-scorer.mdx +11 -3
- package/.docs/raw/reference/evals/faithfulness.mdx +4 -1
- package/.docs/raw/reference/evals/hallucination.mdx +4 -1
- package/.docs/raw/reference/evals/keyword-coverage.mdx +4 -1
- package/.docs/raw/reference/evals/mastra-scorer.mdx +2 -0
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +2 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +9 -7
- package/.docs/raw/reference/evals/run-evals.mdx +3 -1
- package/.docs/raw/reference/evals/scorer-utils.mdx +3 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +4 -1
- package/.docs/raw/reference/evals/tone-consistency.mdx +4 -1
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +25 -23
- package/.docs/raw/reference/evals/toxicity.mdx +4 -1
- package/.docs/raw/reference/index.mdx +2 -1
- package/.docs/raw/reference/logging/pino-logger.mdx +10 -8
- package/.docs/raw/reference/memory/clone-utilities.mdx +345 -0
- package/.docs/raw/reference/memory/cloneThread.mdx +237 -0
- package/.docs/raw/reference/memory/createThread.mdx +6 -4
- package/.docs/raw/reference/memory/deleteMessages.mdx +4 -2
- package/.docs/raw/reference/memory/getThreadById.mdx +3 -1
- package/.docs/raw/reference/memory/listThreads.mdx +187 -0
- package/.docs/raw/reference/memory/memory-class.mdx +27 -20
- package/.docs/raw/reference/memory/recall.mdx +6 -4
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +6 -2
- package/.docs/raw/reference/observability/tracing/configuration.mdx +51 -0
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +25 -6
- package/.docs/raw/reference/observability/tracing/exporters/braintrust.mdx +23 -2
- package/.docs/raw/reference/observability/tracing/exporters/cloud-exporter.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/console-exporter.mdx +3 -0
- package/.docs/raw/reference/observability/tracing/exporters/datadog.mdx +172 -0
- package/.docs/raw/reference/observability/tracing/exporters/default-exporter.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/laminar.mdx +139 -0
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +26 -4
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +51 -34
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +25 -4
- package/.docs/raw/reference/observability/tracing/exporters/sentry.mdx +224 -0
- package/.docs/raw/reference/observability/tracing/instances.mdx +2 -0
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +20 -0
- package/.docs/raw/reference/observability/tracing/processors/sensitive-data-filter.mdx +2 -0
- package/.docs/raw/reference/observability/tracing/spans.mdx +2 -0
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +4 -2
- package/.docs/raw/reference/processors/language-detector.mdx +6 -3
- package/.docs/raw/reference/processors/message-history-processor.mdx +5 -2
- package/.docs/raw/reference/processors/moderation-processor.mdx +6 -4
- package/.docs/raw/reference/processors/pii-detector.mdx +6 -4
- package/.docs/raw/reference/processors/processor-interface.mdx +326 -23
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +5 -3
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +7 -2
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +5 -3
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +62 -19
- package/.docs/raw/reference/processors/tool-call-filter.mdx +5 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +6 -3
- package/.docs/raw/reference/processors/working-memory-processor.mdx +6 -3
- package/.docs/raw/reference/rag/chunk.mdx +7 -6
- package/.docs/raw/reference/rag/database-config.mdx +8 -6
- package/.docs/raw/reference/rag/document.mdx +2 -0
- package/.docs/raw/reference/rag/embeddings.mdx +2 -0
- package/.docs/raw/reference/rag/extract-params.mdx +57 -3
- package/.docs/raw/reference/rag/graph-rag.mdx +2 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +27 -7
- package/.docs/raw/reference/rag/rerank.mdx +2 -0
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +2 -0
- package/.docs/raw/reference/server/create-route.mdx +34 -18
- package/.docs/raw/reference/server/express-adapter.mdx +78 -50
- package/.docs/raw/reference/server/fastify-adapter.mdx +130 -0
- package/.docs/raw/reference/server/hono-adapter.mdx +78 -48
- package/.docs/raw/reference/server/koa-adapter.mdx +129 -0
- package/.docs/raw/reference/server/mastra-server.mdx +52 -34
- package/.docs/raw/reference/server/routes.mdx +73 -10
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +10 -5
- package/.docs/raw/reference/storage/cloudflare.mdx +12 -2
- package/.docs/raw/reference/storage/composite.mdx +245 -0
- package/.docs/raw/reference/storage/convex.mdx +8 -6
- package/.docs/raw/reference/storage/dynamodb.mdx +134 -8
- package/.docs/raw/reference/storage/lance.mdx +9 -5
- package/.docs/raw/reference/storage/libsql.mdx +76 -54
- package/.docs/raw/reference/storage/mongodb.mdx +115 -16
- package/.docs/raw/reference/storage/mssql.mdx +11 -6
- package/.docs/raw/{server-db/storage.mdx → reference/storage/overview.mdx} +15 -111
- package/.docs/raw/reference/storage/postgresql.mdx +228 -83
- package/.docs/raw/reference/storage/upstash.mdx +78 -2
- package/.docs/raw/reference/streaming/ChunkType.mdx +31 -3
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +67 -6
- package/.docs/raw/reference/streaming/agents/stream.mdx +48 -51
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +5 -3
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +3 -1
- package/.docs/raw/reference/streaming/workflows/resumeStream.mdx +3 -1
- package/.docs/raw/reference/streaming/workflows/stream.mdx +37 -22
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +6 -4
- package/.docs/raw/reference/templates/overview.mdx +3 -2
- package/.docs/raw/reference/tools/client.mdx +3 -0
- package/.docs/raw/reference/tools/create-tool.mdx +127 -5
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +2 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +40 -3
- package/.docs/raw/reference/tools/mcp-client.mdx +110 -1
- package/.docs/raw/reference/tools/mcp-server.mdx +278 -24
- package/.docs/raw/reference/tools/vector-query-tool.mdx +68 -4
- package/.docs/raw/reference/vectors/astra.mdx +5 -3
- package/.docs/raw/reference/vectors/chroma.mdx +5 -3
- package/.docs/raw/reference/vectors/convex.mdx +14 -12
- package/.docs/raw/reference/vectors/couchbase.mdx +7 -5
- package/.docs/raw/reference/vectors/duckdb.mdx +12 -10
- package/.docs/raw/reference/vectors/elasticsearch.mdx +12 -4
- package/.docs/raw/reference/vectors/lance.mdx +6 -4
- package/.docs/raw/reference/vectors/libsql.mdx +66 -13
- package/.docs/raw/reference/vectors/mongodb.mdx +90 -10
- package/.docs/raw/reference/vectors/opensearch.mdx +30 -3
- package/.docs/raw/reference/vectors/pg.mdx +58 -6
- package/.docs/raw/reference/vectors/pinecone.mdx +23 -8
- package/.docs/raw/reference/vectors/qdrant.mdx +148 -4
- package/.docs/raw/reference/vectors/s3vectors.mdx +8 -6
- package/.docs/raw/reference/vectors/turbopuffer.mdx +6 -4
- package/.docs/raw/reference/vectors/upstash.mdx +60 -6
- package/.docs/raw/reference/vectors/vectorize.mdx +5 -3
- package/.docs/raw/reference/voice/azure.mdx +2 -0
- package/.docs/raw/reference/voice/cloudflare.mdx +2 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +4 -0
- package/.docs/raw/reference/voice/deepgram.mdx +2 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +2 -0
- package/.docs/raw/reference/voice/google-gemini-live.mdx +3 -0
- package/.docs/raw/reference/voice/google.mdx +2 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +2 -0
- package/.docs/raw/reference/voice/murf.mdx +2 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +3 -0
- package/.docs/raw/reference/voice/openai.mdx +2 -0
- package/.docs/raw/reference/voice/playai.mdx +2 -0
- package/.docs/raw/reference/voice/sarvam.mdx +2 -0
- package/.docs/raw/reference/voice/speechify.mdx +2 -0
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +3 -0
- package/.docs/raw/reference/voice/voice.addTools.mdx +3 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +4 -0
- package/.docs/raw/reference/voice/voice.close.mdx +3 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +5 -1
- package/.docs/raw/reference/voice/voice.events.mdx +2 -0
- package/.docs/raw/reference/voice/voice.getSpeakers.mdx +3 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +6 -0
- package/.docs/raw/reference/voice/voice.off.mdx +2 -0
- package/.docs/raw/reference/voice/voice.on.mdx +5 -1
- package/.docs/raw/reference/voice/voice.send.mdx +4 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +6 -0
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +2 -0
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +55 -5
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +6 -4
- package/.docs/raw/reference/workflows/run-methods/start.mdx +7 -5
- package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +145 -0
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +10 -8
- package/.docs/raw/reference/workflows/run.mdx +11 -3
- package/.docs/raw/reference/workflows/step.mdx +56 -3
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +39 -2
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +71 -4
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +9 -7
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +4 -6
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +4 -6
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow.mdx +193 -2
- package/.docs/raw/{auth → server/auth}/auth0.mdx +40 -21
- package/.docs/raw/{auth → server/auth}/clerk.mdx +37 -16
- package/.docs/raw/{auth → server/auth}/firebase.mdx +47 -25
- package/.docs/raw/{auth → server/auth}/index.mdx +8 -6
- package/.docs/raw/{auth → server/auth}/jwt.mdx +22 -10
- package/.docs/raw/{auth → server/auth}/supabase.mdx +45 -25
- package/.docs/raw/{auth → server/auth}/workos.mdx +39 -20
- package/.docs/raw/{server-db → server}/custom-adapters.mdx +40 -24
- package/.docs/raw/{server-db → server}/custom-api-routes.mdx +6 -6
- package/.docs/raw/{server-db → server}/mastra-client.mdx +35 -38
- package/.docs/raw/server/mastra-server.mdx +86 -0
- package/.docs/raw/{server-db → server}/middleware.mdx +11 -9
- package/.docs/raw/{server-db → server}/request-context.mdx +85 -43
- package/.docs/raw/server/server-adapters.mdx +410 -0
- package/.docs/raw/streaming/events.mdx +16 -7
- package/.docs/raw/streaming/overview.mdx +30 -17
- package/.docs/raw/streaming/tool-streaming.mdx +15 -17
- package/.docs/raw/streaming/workflow-streaming.mdx +8 -8
- package/.docs/raw/tools-mcp/advanced-usage.mdx +4 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +46 -12
- package/.docs/raw/tools-mcp/overview.mdx +14 -13
- package/.docs/raw/voice/overview.mdx +17 -2
- package/.docs/raw/voice/speech-to-speech.mdx +5 -0
- package/.docs/raw/voice/speech-to-text.mdx +4 -0
- package/.docs/raw/voice/text-to-speech.mdx +3 -0
- package/.docs/raw/workflows/agents-and-tools.mdx +70 -21
- package/.docs/raw/workflows/control-flow.mdx +369 -34
- package/.docs/raw/workflows/error-handling.mdx +192 -18
- package/.docs/raw/workflows/human-in-the-loop.mdx +8 -7
- package/.docs/raw/workflows/input-data-mapping.mdx +9 -7
- package/.docs/raw/workflows/overview.mdx +80 -34
- package/.docs/raw/workflows/snapshots.mdx +19 -45
- package/.docs/raw/workflows/suspend-and-resume.mdx +14 -14
- package/.docs/raw/workflows/time-travel.mdx +25 -21
- package/.docs/raw/workflows/workflow-state.mdx +7 -8
- package/CHANGELOG.md +254 -0
- package/README.md +36 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/stdio.js +746 -49
- package/dist/tools/course.d.ts.map +1 -1
- package/dist/tools/embedded-docs.d.ts +276 -0
- package/dist/tools/embedded-docs.d.ts.map +1 -0
- package/package.json +9 -8
- package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +0 -1
- package/.docs/raw/deployment/building-mastra.mdx +0 -73
- package/.docs/raw/deployment/cloud-providers/index.mdx +0 -55
- package/.docs/raw/deployment/mastra-cloud/dashboard.mdx +0 -100
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +0 -53
- package/.docs/raw/deployment/mastra-cloud/overview.mdx +0 -65
- package/.docs/raw/deployment/mastra-cloud/setting-up.mdx +0 -105
- package/.docs/raw/memory/conversation-history.mdx +0 -24
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +0 -140
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +0 -150
- package/.docs/raw/memory/storage/memory-with-pg.mdx +0 -138
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +0 -146
- package/.docs/raw/memory/threads-and-resources.mdx +0 -95
- package/.docs/raw/reference/core/setTelemetry.mdx +0 -36
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +0 -110
- package/.docs/raw/reference/memory/query.mdx +0 -189
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +0 -70
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +0 -66
- package/.docs/raw/server-db/mastra-server.mdx +0 -97
- package/.docs/raw/server-db/server-adapters.mdx +0 -286
- package/.docs/raw/workflows/inngest-workflow.mdx +0 -363
|
@@ -1,203 +1,432 @@
|
|
|
1
1
|
# @mastra/core
|
|
2
2
|
|
|
3
|
-
## 1.0.0
|
|
3
|
+
## 1.0.0
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Major Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Moving scorers under the eval domain, api method consistency, prebuilt evals, scorers require ids. ([#9589](https://github.com/mastra-ai/mastra/pull/9589))
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
9
|
+
- Scorers for Agents will now use `MastraDBMessage` instead of `UIMessage` ([#9702](https://github.com/mastra-ai/mastra/pull/9702))
|
|
10
|
+
- Scorer input/output types now use `MastraDBMessage[]` with nested `content` object structure
|
|
11
|
+
- Added `getTextContentFromMastraDBMessage()` helper function to extract text content from `MastraDBMessage` objects
|
|
12
|
+
- Added `createTestMessage()` helper function for creating `MastraDBMessage` objects in tests with optional tool invocations support
|
|
13
|
+
- Updated `extractToolCalls()` to access tool invocations from nested `content` structure
|
|
14
|
+
- Updated `getUserMessageFromRunInput()` and `getAssistantMessageFromRunOutput()` to use new message structure
|
|
15
|
+
- Removed `createUIMessage()`
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
Previously, calling getScoreById after saveScore would return null because the generated ID wasn't persisted to the database. This is now fixed across all store implementations, ensuring consistent behavior and data integrity.
|
|
17
|
+
- Every Mastra primitive (agent, MCPServer, workflow, tool, processor, scorer, and vector) now has a get, list, and add method associated with it. Each primitive also now requires an id to be set. ([#9675](https://github.com/mastra-ai/mastra/pull/9675))
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
- `setState` must now be awaited: `await setState({ key: value })`
|
|
18
|
-
- State updates are merged automatically—no need to spread the previous state
|
|
19
|
-
- State data is validated against the step's `stateSchema` when `validateInputs` is enabled (default: `true`)
|
|
19
|
+
Primitives that are added to other primitives are also automatically added to the Mastra instance
|
|
20
20
|
|
|
21
|
-
-
|
|
21
|
+
- Update handlers to use `listWorkflowRuns` instead of `getWorkflowRuns`. Fix type names from `StoragelistThreadsByResourceIdInput/Output` to `StorageListThreadsByResourceIdInput/Output`. ([#9507](https://github.com/mastra-ai/mastra/pull/9507))
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
- Refactor workflow and tool types to remove Zod-specific constraints ([#11814](https://github.com/mastra-ai/mastra/pull/11814))
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Removed Zod-specific type constraints across all workflow implementations and tool types, replacing them with generic types. This ensures type consistency across default, evented, and inngest workflows while preparing for Zod v4 migration.
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
**Workflow Changes:**
|
|
28
|
+
- Removed `z.ZodObject<any>` and `z.ZodType<any>` constraints from all workflow generic types
|
|
29
|
+
- Updated method signatures to use `TInput` and `TState` directly instead of `z.infer<TInput>` and `z.infer<TState>`
|
|
30
|
+
- Aligned conditional types across all workflow implementations using `TInput extends unknown` pattern
|
|
31
|
+
- Fixed `TSteps` generic to properly use `TEngineType` instead of `any`
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
**Tool Changes:**
|
|
34
|
+
- Removed Zod schema constraints from `ToolExecutionContext` and related interfaces
|
|
35
|
+
- Simplified type parameters from `TSuspendSchema extends ZodLikeSchema` to `TSuspend` and `TResume`
|
|
36
|
+
- Updated tool execution context types to use generic types
|
|
37
|
+
|
|
38
|
+
**Type Utilities:**
|
|
39
|
+
- Refactored type helpers to work with generic schemas instead of Zod-specific types
|
|
40
|
+
- Updated type extraction utilities for better compatibility
|
|
41
|
+
|
|
42
|
+
This change maintains backward compatibility while improving type consistency and preparing for Zod v4 support across all affected packages.
|
|
43
|
+
|
|
44
|
+
- Remove `getMessagesPaginated()` and add `perPage: false` support ([#9670](https://github.com/mastra-ai/mastra/pull/9670))
|
|
45
|
+
|
|
46
|
+
Removes deprecated `getMessagesPaginated()` method. The `listMessages()` API and score handlers now support `perPage: false` to fetch all records without pagination limits.
|
|
47
|
+
|
|
48
|
+
**Storage changes:**
|
|
49
|
+
- `StoragePagination.perPage` type changed from `number` to `number | false`
|
|
50
|
+
- All storage implementations support `perPage: false`:
|
|
51
|
+
- Memory: `listMessages()`
|
|
52
|
+
- Scores: `listScoresBySpan()`, `listScoresByRunId()`, `listScoresByExecutionId()`
|
|
53
|
+
- HTTP query parser accepts `"false"` string (e.g., `?perPage=false`)
|
|
54
|
+
|
|
55
|
+
**Memory changes:**
|
|
56
|
+
- `memory.query()` parameter type changed from `StorageGetMessagesArg` to `StorageListMessagesInput`
|
|
57
|
+
- Uses flat parameters (`page`, `perPage`, `include`, `filter`, `vectorSearchString`) instead of `selectBy` object
|
|
58
|
+
|
|
59
|
+
**Stricter validation:**
|
|
60
|
+
- `listMessages()` requires non-empty, non-whitespace `threadId` (throws error instead of returning empty results)
|
|
61
|
+
|
|
62
|
+
**Migration:**
|
|
30
63
|
|
|
31
64
|
```typescript
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
65
|
+
// Storage/Memory: Replace getMessagesPaginated with listMessages
|
|
66
|
+
- storage.getMessagesPaginated({ threadId, selectBy: { pagination: { page: 0, perPage: 20 } } })
|
|
67
|
+
+ storage.listMessages({ threadId, page: 0, perPage: 20 })
|
|
68
|
+
+ storage.listMessages({ threadId, page: 0, perPage: false }) // Fetch all
|
|
69
|
+
|
|
70
|
+
// Memory: Replace selectBy with flat parameters
|
|
71
|
+
- memory.query({ threadId, selectBy: { last: 20, include: [...] } })
|
|
72
|
+
+ memory.query({ threadId, perPage: 20, include: [...] })
|
|
73
|
+
|
|
74
|
+
// Client SDK
|
|
75
|
+
- thread.getMessagesPaginated({ selectBy: { pagination: { page: 0 } } })
|
|
76
|
+
+ thread.listMessages({ page: 0, perPage: 20 })
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- **Removed `storage.getMessages()`** ([#9695](https://github.com/mastra-ai/mastra/pull/9695))
|
|
80
|
+
|
|
81
|
+
The `getMessages()` method has been removed from all storage implementations. Use `listMessages()` instead, which provides pagination support.
|
|
82
|
+
|
|
83
|
+
**Migration:**
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// Before
|
|
87
|
+
const messages = await storage.getMessages({ threadId: 'thread-1' });
|
|
88
|
+
|
|
89
|
+
// After
|
|
90
|
+
const result = await storage.listMessages({
|
|
91
|
+
threadId: 'thread-1',
|
|
92
|
+
page: 0,
|
|
93
|
+
perPage: 50,
|
|
36
94
|
});
|
|
37
|
-
|
|
95
|
+
const messages = result.messages; // Access messages array
|
|
96
|
+
console.log(result.total); // Total count
|
|
97
|
+
console.log(result.hasMore); // Whether more pages exist
|
|
98
|
+
```
|
|
38
99
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
100
|
+
**Message ordering default**
|
|
101
|
+
|
|
102
|
+
`listMessages()` defaults to ASC (oldest first) ordering by `createdAt`, matching the previous `getMessages()` behavior.
|
|
103
|
+
|
|
104
|
+
**To use DESC ordering (newest first):**
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
const result = await storage.listMessages({
|
|
108
|
+
threadId: 'thread-1',
|
|
109
|
+
orderBy: { field: 'createdAt', direction: 'DESC' },
|
|
44
110
|
});
|
|
45
111
|
```
|
|
46
112
|
|
|
47
|
-
|
|
113
|
+
**Renamed `client.getThreadMessages()` → `client.listThreadMessages()`**
|
|
48
114
|
|
|
49
|
-
|
|
115
|
+
**Migration:**
|
|
50
116
|
|
|
51
|
-
|
|
117
|
+
```typescript
|
|
118
|
+
// Before
|
|
119
|
+
const response = await client.getThreadMessages(threadId, { agentId });
|
|
120
|
+
|
|
121
|
+
// After
|
|
122
|
+
const response = await client.listThreadMessages(threadId, { agentId });
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The response format remains the same.
|
|
126
|
+
|
|
127
|
+
**Removed `StorageGetMessagesArg` type**
|
|
128
|
+
|
|
129
|
+
Use `StorageListMessagesInput` instead:
|
|
52
130
|
|
|
53
131
|
```typescript
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
132
|
+
// Before
|
|
133
|
+
import type { StorageGetMessagesArg } from '@mastra/core';
|
|
134
|
+
|
|
135
|
+
// After
|
|
136
|
+
import type { StorageListMessagesInput } from '@mastra/core';
|
|
57
137
|
```
|
|
58
138
|
|
|
59
|
-
-
|
|
60
|
-
|
|
139
|
+
- - Removes modelSettings.abortSignal in favour of top-level abortSignal only. Also removes the deprecated output field - use structuredOutput.schema instead. ([`9e1911d`](https://github.com/mastra-ai/mastra/commit/9e1911db2b4db85e0e768c3f15e0d61e319869f6))
|
|
140
|
+
- The deprecated generateVNext() and streamVNext() methods have been removed since they're now the stable generate() and stream() methods.
|
|
141
|
+
- The deprecated `output` option has been removed entirely, in favour of `structuredOutput`.
|
|
61
142
|
|
|
62
|
-
|
|
143
|
+
Method renames to clarify the API surface:
|
|
144
|
+
- getDefaultGenerateOptions → getDefaultGenerateOptionsLegacy
|
|
145
|
+
- getDefaultStreamOptions → getDefaultStreamOptionsLegacy
|
|
146
|
+
- getDefaultVNextStreamOptions → getDefaultStreamOptions
|
|
63
147
|
|
|
64
|
-
-
|
|
148
|
+
- Bump minimum required Node.js version to 22.13.0 ([#9706](https://github.com/mastra-ai/mastra/pull/9706))
|
|
65
149
|
|
|
66
|
-
|
|
150
|
+
- Replace `getThreadsByResourceIdPaginated` with `listThreadsByResourceId` across memory handlers. Update client SDK to use `listThreads()` with `offset`/`limit` parameters instead of deprecated `getMemoryThreads()`. Consolidate `/api/memory/threads` routes to single paginated endpoint. ([#9508](https://github.com/mastra-ai/mastra/pull/9508))
|
|
67
151
|
|
|
68
|
-
|
|
152
|
+
- Add new list methods to storage API: `listMessages`, `listMessagesById`, `listThreadsByResourceId`, and `listWorkflowRuns`. Most methods are currently wrappers around existing methods. Full implementations will be added when migrating away from legacy methods. ([#9489](https://github.com/mastra-ai/mastra/pull/9489))
|
|
69
153
|
|
|
70
|
-
|
|
154
|
+
- Update tool execution signature ([#9587](https://github.com/mastra-ai/mastra/pull/9587))
|
|
155
|
+
|
|
156
|
+
Consolidated the 3 different execution contexts to one
|
|
71
157
|
|
|
72
|
-
|
|
158
|
+
```typescript
|
|
159
|
+
// before depending on the context the tool was executed in
|
|
160
|
+
tool.execute({ context: data });
|
|
161
|
+
tool.execute({ context: { inputData: data } });
|
|
162
|
+
tool.execute(data);
|
|
73
163
|
|
|
74
|
-
|
|
164
|
+
// now, for all contexts
|
|
165
|
+
tool.execute(data, context);
|
|
166
|
+
```
|
|
75
167
|
|
|
76
|
-
|
|
168
|
+
**Before:**
|
|
77
169
|
|
|
78
|
-
|
|
170
|
+
```typescript
|
|
171
|
+
inputSchema: z.object({ something: z.string() }),
|
|
172
|
+
execute: async ({ context, tracingContext, runId, ... }) => {
|
|
173
|
+
return doSomething(context.string);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**After:**
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
inputSchema: z.object({ something: z.string() }),
|
|
181
|
+
execute: async (inputData, context) => {
|
|
182
|
+
const { agent, mcp, workflow, ...sharedContext } = context
|
|
183
|
+
|
|
184
|
+
// context that only an agent would get like toolCallId, messages, suspend, resume, etc
|
|
185
|
+
if (agent) {
|
|
186
|
+
doSomething(inputData.something, agent)
|
|
187
|
+
// context that only a workflow would get like runId, state, suspend, resume, etc
|
|
188
|
+
} else if (workflow) {
|
|
189
|
+
doSomething(inputData.something, workflow)
|
|
190
|
+
// context that only a workflow would get like "extra", "elicitation"
|
|
191
|
+
} else if (mcp) {
|
|
192
|
+
doSomething(inputData.something, mcp)
|
|
193
|
+
} else {
|
|
194
|
+
// Running a tool in no execution context
|
|
195
|
+
return doSomething(inputData.something);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
- The `@mastra/core` package no longer allows top-level imports except for `Mastra` and `type Config`. You must use subpath imports for all other imports. ([#9544](https://github.com/mastra-ai/mastra/pull/9544))
|
|
201
|
+
|
|
202
|
+
For example:
|
|
203
|
+
|
|
204
|
+
```diff
|
|
205
|
+
import { Mastra, type Config } from "@mastra/core";
|
|
206
|
+
- import { Agent } from "@mastra/core";
|
|
207
|
+
- import { createTool } from "@mastra/core";
|
|
208
|
+
- import { createStep } from "@mastra/core";
|
|
209
|
+
|
|
210
|
+
+ import { Agent } from "@mastra/core/agent";
|
|
211
|
+
+ import { createTool } from "@mastra/core/tools";
|
|
212
|
+
+ import { createStep } from "@mastra/core/workflows";
|
|
213
|
+
```
|
|
79
214
|
|
|
80
|
-
-
|
|
215
|
+
- This simplifies the Memory API by removing the confusing rememberMessages method and renaming query to recall for better clarity. ([#9701](https://github.com/mastra-ai/mastra/pull/9701))
|
|
81
216
|
|
|
82
|
-
|
|
217
|
+
The rememberMessages method name implied it might persist data when it was actually just retrieving messages, same as query. Having two methods that did essentially the same thing was unnecessary.
|
|
83
218
|
|
|
84
219
|
Before:
|
|
85
220
|
|
|
86
221
|
```typescript
|
|
87
|
-
//
|
|
88
|
-
|
|
222
|
+
// Two methods that did the same thing
|
|
223
|
+
memory.rememberMessages({ threadId, resourceId, config, vectorMessageSearch });
|
|
224
|
+
memory.query({ threadId, resourceId, perPage, vectorSearchString });
|
|
89
225
|
```
|
|
90
226
|
|
|
91
227
|
After:
|
|
92
228
|
|
|
93
229
|
```typescript
|
|
94
|
-
//
|
|
95
|
-
|
|
230
|
+
// Single unified method with clear purpose
|
|
231
|
+
memory.recall({ threadId, resourceId, perPage, vectorMessageSearch, threadConfig });
|
|
96
232
|
```
|
|
97
233
|
|
|
98
|
-
|
|
234
|
+
All usages have been updated across the codebase including tests. The agent now calls recall directly with the appropriate parameters.
|
|
99
235
|
|
|
100
|
-
-
|
|
236
|
+
- Rename RuntimeContext to RequestContext ([#9511](https://github.com/mastra-ai/mastra/pull/9511))
|
|
237
|
+
|
|
238
|
+
- Implement listMessages API for replacing previous methods ([#9531](https://github.com/mastra-ai/mastra/pull/9531))
|
|
239
|
+
|
|
240
|
+
- Rename `defaultVNextStreamOptions` to `defaultOptions`. Add "Legacy" suffix to v1 option properties and methods (`defaultGenerateOptions` → `defaultGenerateOptionsLegacy`, `defaultStreamOptions` → `defaultStreamOptionsLegacy`). ([#9535](https://github.com/mastra-ai/mastra/pull/9535))
|
|
241
|
+
|
|
242
|
+
- **Breaking Change**: Convert OUTPUT generic from `OutputSchema` constraint to plain generic ([#11741](https://github.com/mastra-ai/mastra/pull/11741))
|
|
243
|
+
|
|
244
|
+
This change removes the direct dependency on Zod typings in the public API by converting all `OUTPUT extends OutputSchema` generic constraints to plain `OUTPUT` generics throughout the codebase. This is preparation for moving to a standard schema approach.
|
|
245
|
+
- All generic type parameters previously constrained to `OutputSchema` (e.g., `<OUTPUT extends OutputSchema = undefined>`) are now plain generics with defaults (e.g., `<OUTPUT = undefined>`)
|
|
246
|
+
- Affects all public APIs including `Agent`, `MastraModelOutput`, `AgentExecutionOptions`, and stream/generate methods
|
|
247
|
+
- `InferSchemaOutput<OUTPUT>` replaced with `OUTPUT` throughout
|
|
248
|
+
- `PartialSchemaOutput<OUTPUT>` replaced with `Partial<OUTPUT>`
|
|
249
|
+
- Schema fields now use `NonNullable<OutputSchema<OUTPUT>>` instead of `OUTPUT` directly
|
|
250
|
+
- Added `FullOutput<OUTPUT>` type representing complete output with all fields
|
|
251
|
+
- Added `AgentExecutionOptionsBase<OUTPUT>` type
|
|
252
|
+
- `getFullOutput()` method now returns `Promise<FullOutput<OUTPUT>>`
|
|
253
|
+
- `Agent` class now generic: `Agent<TAgentId, TTools, TOutput>`
|
|
254
|
+
- `agent.generate()` and `agent.stream()` methods have updated signatures
|
|
255
|
+
- `MastraModelOutput<OUTPUT>` no longer requires `OutputSchema` constraint
|
|
256
|
+
- Network route and streaming APIs updated to use plain OUTPUT generic
|
|
101
257
|
|
|
102
258
|
**Before:**
|
|
103
259
|
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
saveThread: false, // thread not in DB yet
|
|
260
|
+
```typescript
|
|
261
|
+
const output = await agent.generate<z.ZodType>([...], {
|
|
262
|
+
structuredOutput: { schema: mySchema }
|
|
108
263
|
});
|
|
109
|
-
// Later: MessageHistory calls saveMessages() -> PostgresStore throws "Thread not found"
|
|
110
|
-
```
|
|
111
264
|
|
|
112
265
|
**After:**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
threadObject = await memory.createThread({
|
|
116
|
-
// ...
|
|
117
|
-
saveThread: true, // thread persisted immediately
|
|
266
|
+
const output = await agent.generate<z.infer<typeof mySchema>>([...], {
|
|
267
|
+
structuredOutput: { schema: mySchema }
|
|
118
268
|
});
|
|
119
|
-
//
|
|
269
|
+
// Or rely on type inference:
|
|
270
|
+
const output = await agent.generate([...], {
|
|
271
|
+
structuredOutput: { schema: mySchema }
|
|
272
|
+
});
|
|
273
|
+
|
|
120
274
|
```
|
|
121
275
|
|
|
122
|
-
-
|
|
276
|
+
- Remove `getThreadsByResourceId` and `getThreadsByResourceIdPaginated` methods from storage interfaces in favor of `listThreadsByResourceId`. The new method uses `offset`/`limit` pagination and a nested `orderBy` object structure (`{ field, direction }`). ([#9536](https://github.com/mastra-ai/mastra/pull/9536))
|
|
123
277
|
|
|
124
|
-
|
|
278
|
+
- Remove `getMessagesById` method from storage interfaces in favor of `listMessagesById`. The new method only returns V2-format messages and removes the format parameter, simplifying the API surface. Users should migrate from `getMessagesById({ messageIds, format })` to `listMessagesById({ messageIds })`. ([#9534](https://github.com/mastra-ai/mastra/pull/9534))
|
|
125
279
|
|
|
126
|
-
-
|
|
280
|
+
- Experimental auth -> auth ([#9660](https://github.com/mastra-ai/mastra/pull/9660))
|
|
127
281
|
|
|
128
|
-
-
|
|
282
|
+
- Renamed a bunch of observability/tracing-related things to drop the AI prefix. ([#9744](https://github.com/mastra-ai/mastra/pull/9744))
|
|
283
|
+
|
|
284
|
+
- Removed MastraMessageV3 intermediary format, now we go from MastraDBMessage->aiv5 formats and back directly ([#9094](https://github.com/mastra-ai/mastra/pull/9094))
|
|
285
|
+
|
|
286
|
+
- **Breaking Change**: Remove legacy v1 watch events and consolidate on v2 implementation. ([#9252](https://github.com/mastra-ai/mastra/pull/9252))
|
|
287
|
+
|
|
288
|
+
This change simplifies the workflow watching API by removing the legacy v1 event system and promoting v2 as the standard (renamed to just `watch`).
|
|
289
|
+
|
|
290
|
+
**What's Changed**
|
|
291
|
+
- Removed legacy v1 watch event handlers and types
|
|
292
|
+
- Renamed `watch-v2` to `watch` throughout the codebase
|
|
293
|
+
- Removed `.watch()` method from client-js SDK (`Workflow` and `AgentBuilder` classes)
|
|
294
|
+
- Removed `/watch` HTTP endpoints from server and deployer
|
|
295
|
+
- Removed `WorkflowWatchResult` and v1 `WatchEvent` types
|
|
296
|
+
|
|
297
|
+
- Remove various deprecated APIs from agent class. ([#9257](https://github.com/mastra-ai/mastra/pull/9257))
|
|
298
|
+
- `agent.llm` → `agent.getLLM()`
|
|
299
|
+
- `agent.tools` → `agent.getTools()`
|
|
300
|
+
- `agent.instructions` → `agent.getInstructions()`
|
|
301
|
+
- `agent.speak()` → `agent.voice.speak()`
|
|
302
|
+
- `agent.getSpeakers()` → `agent.voice.getSpeakers()`
|
|
303
|
+
- `agent.listen` → `agent.voice.listen()`
|
|
304
|
+
- `agent.fetchMemory` → `(await agent.getMemory()).query()`
|
|
305
|
+
- `agent.toStep` → Add agent directly to the step, workflows handle the transformation
|
|
306
|
+
|
|
307
|
+
- Pagination APIs now use `page`/`perPage` instead of `offset`/`limit` ([#9592](https://github.com/mastra-ai/mastra/pull/9592))
|
|
308
|
+
|
|
309
|
+
All storage and memory pagination APIs have been updated to use `page` (0-indexed) and `perPage` instead of `offset` and `limit`, aligning with standard REST API patterns.
|
|
310
|
+
|
|
311
|
+
**Affected APIs:**
|
|
312
|
+
- `Memory.listThreadsByResourceId()`
|
|
313
|
+
- `Memory.listMessages()`
|
|
314
|
+
- `Storage.listWorkflowRuns()`
|
|
315
|
+
|
|
316
|
+
**Migration:**
|
|
129
317
|
|
|
130
318
|
```typescript
|
|
131
|
-
|
|
132
|
-
|
|
319
|
+
// Before
|
|
320
|
+
await memory.listThreadsByResourceId({
|
|
321
|
+
resourceId: 'user-123',
|
|
322
|
+
offset: 20,
|
|
323
|
+
limit: 10,
|
|
133
324
|
});
|
|
134
325
|
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
},
|
|
141
|
-
},
|
|
326
|
+
// After
|
|
327
|
+
await memory.listThreadsByResourceId({
|
|
328
|
+
resourceId: 'user-123',
|
|
329
|
+
page: 2, // page = Math.floor(offset / limit)
|
|
330
|
+
perPage: 10,
|
|
142
331
|
});
|
|
143
|
-
```
|
|
144
332
|
|
|
145
|
-
|
|
333
|
+
// Before
|
|
334
|
+
await memory.listMessages({
|
|
335
|
+
threadId: 'thread-456',
|
|
336
|
+
offset: 20,
|
|
337
|
+
limit: 10,
|
|
338
|
+
});
|
|
146
339
|
|
|
147
|
-
|
|
340
|
+
// After
|
|
341
|
+
await memory.listMessages({
|
|
342
|
+
threadId: 'thread-456',
|
|
343
|
+
page: 2,
|
|
344
|
+
perPage: 10,
|
|
345
|
+
});
|
|
148
346
|
|
|
149
|
-
|
|
347
|
+
// Before
|
|
348
|
+
await storage.listWorkflowRuns({
|
|
349
|
+
workflowName: 'my-workflow',
|
|
350
|
+
offset: 20,
|
|
351
|
+
limit: 10,
|
|
352
|
+
});
|
|
150
353
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
354
|
+
// After
|
|
355
|
+
await storage.listWorkflowRuns({
|
|
356
|
+
workflowName: 'my-workflow',
|
|
357
|
+
page: 2,
|
|
358
|
+
perPage: 10,
|
|
359
|
+
});
|
|
360
|
+
```
|
|
156
361
|
|
|
157
|
-
|
|
362
|
+
**Additional improvements:**
|
|
363
|
+
- Added validation for negative `page` values in all storage implementations
|
|
364
|
+
- Improved `perPage` validation to handle edge cases (negative values, `0`, `false`)
|
|
365
|
+
- Added reusable query parser utilities for consistent validation in handlers
|
|
158
366
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
367
|
+
- ```ts ([#9709](https://github.com/mastra-ai/mastra/pull/9709))
|
|
368
|
+
import { Mastra } from '@mastra/core';
|
|
369
|
+
import { Observability } from '@mastra/observability'; // Explicit import
|
|
162
370
|
|
|
163
|
-
|
|
164
|
-
|
|
371
|
+
const mastra = new Mastra({
|
|
372
|
+
...other_config,
|
|
373
|
+
observability: new Observability({
|
|
374
|
+
default: { enabled: true },
|
|
375
|
+
}), // Instance
|
|
376
|
+
});
|
|
377
|
+
```
|
|
165
378
|
|
|
166
|
-
|
|
167
|
-
GET /api/workflows?partial=true
|
|
379
|
+
Instead of:
|
|
168
380
|
|
|
169
|
-
|
|
170
|
-
|
|
381
|
+
```ts
|
|
382
|
+
import { Mastra } from '@mastra/core';
|
|
383
|
+
import '@mastra/observability/init'; // Explicit import
|
|
384
|
+
|
|
385
|
+
const mastra = new Mastra({
|
|
386
|
+
...other_config,
|
|
387
|
+
observability: {
|
|
388
|
+
default: { enabled: true },
|
|
389
|
+
},
|
|
390
|
+
});
|
|
171
391
|
```
|
|
172
392
|
|
|
173
|
-
|
|
393
|
+
Also renamed a bunch of:
|
|
394
|
+
- `Tracing` things to `Observability` things.
|
|
395
|
+
- `AI-` things to just things.
|
|
174
396
|
|
|
175
|
-
|
|
176
|
-
import { MastraClient } from '@mastra/client-js';
|
|
397
|
+
- Changing getAgents -> listAgents, getTools -> listTools, getWorkflows -> listWorkflows ([#9495](https://github.com/mastra-ai/mastra/pull/9495))
|
|
177
398
|
|
|
178
|
-
|
|
399
|
+
- Removed old tracing code based on OpenTelemetry ([#9237](https://github.com/mastra-ai/mastra/pull/9237))
|
|
179
400
|
|
|
180
|
-
|
|
181
|
-
const partialAgents = await client.listAgents({ partial: true });
|
|
401
|
+
- Remove deprecated vector prompts and cohere provider from code ([#9596](https://github.com/mastra-ai/mastra/pull/9596))
|
|
182
402
|
|
|
183
|
-
|
|
184
|
-
const fullAgents = await client.listAgents();
|
|
403
|
+
- Renamed MastraStorage to MastraCompositeStore for better clarity. The old MastraStorage name remains available as a deprecated alias for backward compatibility, but will be removed in a future version. ([#12093](https://github.com/mastra-ai/mastra/pull/12093))
|
|
185
404
|
|
|
186
|
-
|
|
187
|
-
const partialWorkflows = await client.listWorkflows({ partial: true });
|
|
405
|
+
**Migration:**
|
|
188
406
|
|
|
189
|
-
|
|
190
|
-
const fullWorkflows = await client.listWorkflows();
|
|
191
|
-
```
|
|
407
|
+
Update your imports and usage:
|
|
192
408
|
|
|
193
|
-
|
|
409
|
+
```typescript
|
|
410
|
+
// Before
|
|
411
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
194
412
|
|
|
195
|
-
|
|
196
|
-
|
|
413
|
+
const storage = new MastraStorage({
|
|
414
|
+
id: 'composite',
|
|
415
|
+
domains: { ... }
|
|
416
|
+
});
|
|
197
417
|
|
|
198
|
-
|
|
418
|
+
// After
|
|
419
|
+
import { MastraCompositeStore } from '@mastra/core/storage';
|
|
199
420
|
|
|
200
|
-
|
|
421
|
+
const storage = new MastraCompositeStore({
|
|
422
|
+
id: 'composite',
|
|
423
|
+
domains: { ... }
|
|
424
|
+
});
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
The new name better reflects that this is a composite storage implementation that routes different domains (workflows, traces, messages) to different underlying stores, avoiding confusion with the general "Mastra Storage" concept.
|
|
428
|
+
|
|
429
|
+
- Mark as stable ([`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc))
|
|
201
430
|
|
|
202
431
|
- Changed `.branch()` result schema to make all branch output fields optional. ([#10693](https://github.com/mastra-ai/mastra/pull/10693))
|
|
203
432
|
|
|
@@ -236,267 +465,3108 @@
|
|
|
236
465
|
|
|
237
466
|
Related issue: https://github.com/mastra-ai/mastra/issues/10642
|
|
238
467
|
|
|
239
|
-
|
|
468
|
+
- Enforcing id required on Processor primitive ([#9591](https://github.com/mastra-ai/mastra/pull/9591))
|
|
240
469
|
|
|
241
|
-
-
|
|
470
|
+
- **Breaking Changes:** ([#9045](https://github.com/mastra-ai/mastra/pull/9045))
|
|
471
|
+
- Moved `generateTitle` from `threads.generateTitle` to top-level memory option
|
|
472
|
+
- Changed default value from `true` to `false`
|
|
473
|
+
- Using `threads.generateTitle` now throws an error
|
|
242
474
|
|
|
243
|
-
|
|
475
|
+
**Migration:**
|
|
476
|
+
Replace `threads: { generateTitle: true }` with `generateTitle: true` at the top level of memory options.
|
|
244
477
|
|
|
245
|
-
|
|
478
|
+
**Playground:**
|
|
479
|
+
The playground UI now displays thread IDs instead of "Chat from" when titles aren't generated.
|
|
246
480
|
|
|
247
|
-
-
|
|
481
|
+
- Renamed `MastraMessageV2` to `MastraDBMessage` ([#9255](https://github.com/mastra-ai/mastra/pull/9255))
|
|
482
|
+
Made the return format of all methods that return db messages consistent. It's always `{ messages: MastraDBMessage[] }` now, and messages can be converted after that using `@mastra/ai-sdk/ui`'s `toAISdkV4/5Messages()` function
|
|
248
483
|
|
|
249
|
-
|
|
484
|
+
- moved ai-tracing code into @mastra/observability ([#9661](https://github.com/mastra-ai/mastra/pull/9661))
|
|
250
485
|
|
|
251
|
-
|
|
252
|
-
- `suspendData` parameter automatically populated in step execute function when resuming
|
|
253
|
-
- Type-safe access to suspend data matching the step's `suspendSchema`
|
|
254
|
-
- Backward compatible - existing workflows continue to work unchanged
|
|
486
|
+
- Remove legacy evals from Mastra ([#9491](https://github.com/mastra-ai/mastra/pull/9491))
|
|
255
487
|
|
|
256
|
-
|
|
488
|
+
- Use tool's outputSchema to validate results and return an error object if schema does not match output results. ([#9664](https://github.com/mastra-ai/mastra/pull/9664))
|
|
257
489
|
|
|
258
490
|
```typescript
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
console.log(`Resuming after: ${suspendData?.reason}`);
|
|
269
|
-
return { result: 'Approved' };
|
|
491
|
+
const getUserTool = createTool({
|
|
492
|
+
id: 'get-user',
|
|
493
|
+
outputSchema: z.object({
|
|
494
|
+
id: z.string(),
|
|
495
|
+
name: z.string(),
|
|
496
|
+
email: z.string().email(),
|
|
497
|
+
}),
|
|
498
|
+
execute: async inputData => {
|
|
499
|
+
return { id: '123', name: 'John' };
|
|
270
500
|
},
|
|
271
501
|
});
|
|
272
502
|
```
|
|
273
503
|
|
|
274
|
-
|
|
275
|
-
- Fixed TypeScript errors where `threadId: string | string[]` was being passed to places expecting `Scalar` type
|
|
276
|
-
- Added proper multi-thread support for `listMessages` across all adapters when `threadId` is an array
|
|
277
|
-
- Updated `_getIncludedMessages` to look up message threadId by ID (since message IDs are globally unique)
|
|
278
|
-
- **upstash**: Added `msg-idx:{messageId}` index for O(1) message lookups (backwards compatible with fallback to scan for old messages, with automatic backfill)
|
|
279
|
-
|
|
280
|
-
- Adds trace tagging support to the BrainTrust and Langfuse tracing exporters. ([#10765](https://github.com/mastra-ai/mastra/pull/10765))
|
|
504
|
+
When validation fails, the tool returns a `ValidationError`:
|
|
281
505
|
|
|
282
|
-
|
|
506
|
+
```typescript
|
|
507
|
+
// Before v1 - invalid output would silently pass through
|
|
508
|
+
await getUserTool.execute({});
|
|
509
|
+
// { id: "123", name: "John" } - missing email
|
|
510
|
+
|
|
511
|
+
// After v1 - validation error is returned
|
|
512
|
+
await getUserTool.execute({});
|
|
513
|
+
// {
|
|
514
|
+
// error: true,
|
|
515
|
+
// message: "Tool output validation failed for get-user. The tool returned invalid output:\n- email: Required\n\nReturned output: {...}",
|
|
516
|
+
// validationErrors: { ... }
|
|
517
|
+
// }
|
|
518
|
+
```
|
|
283
519
|
|
|
284
|
-
-
|
|
520
|
+
- Removes deprecated input-processor type and processors. ([#9200](https://github.com/mastra-ai/mastra/pull/9200))
|
|
285
521
|
|
|
286
|
-
|
|
287
|
-
- `preferredTimestampFields`: Preferred source fields for timestamps (PostgreSQL, Cloudflare D1)
|
|
288
|
-
- `convertTimestamps`: Convert timestamp strings to Date objects (MSSQL, MongoDB, ClickHouse)
|
|
289
|
-
- `nullValuePattern`: Skip values matching pattern (ClickHouse's `'_null_'`)
|
|
290
|
-
- `fieldMappings`: Map source column names to schema fields (LibSQL's `additionalLLMContext`)
|
|
522
|
+
### Minor Changes
|
|
291
523
|
|
|
292
|
-
|
|
524
|
+
- Add context parameter to `idGenerator` to enable deterministic ID generation based on context. ([#10964](https://github.com/mastra-ai/mastra/pull/10964))
|
|
293
525
|
|
|
294
|
-
|
|
526
|
+
The `idGenerator` function now receives optional context about what type of ID is being generated and from which Mastra primitive. This allows generating IDs that can be shared with external databases.
|
|
295
527
|
|
|
296
|
-
|
|
297
|
-
|
|
528
|
+
```typescript
|
|
529
|
+
const mastra = new Mastra({
|
|
530
|
+
idGenerator: context => {
|
|
531
|
+
// context.idType: 'thread' | 'message' | 'run' | 'step' | 'generic'
|
|
532
|
+
// context.source: 'agent' | 'workflow' | 'memory'
|
|
533
|
+
// context.entityId: the agent/workflow id
|
|
534
|
+
// context.threadId, context.resourceId, context.role, context.stepType
|
|
535
|
+
|
|
536
|
+
if (context?.idType === 'message' && context?.threadId) {
|
|
537
|
+
return `msg-${context.threadId}-${Date.now()}`;
|
|
538
|
+
}
|
|
539
|
+
if (context?.idType === 'run' && context?.source === 'agent') {
|
|
540
|
+
return `run-${context.entityId}-${Date.now()}`;
|
|
541
|
+
}
|
|
542
|
+
return crypto.randomUUID();
|
|
543
|
+
},
|
|
544
|
+
});
|
|
545
|
+
```
|
|
298
546
|
|
|
299
|
-
|
|
547
|
+
Existing `idGenerator` functions without parameters continue to work since the context is optional.
|
|
300
548
|
|
|
301
|
-
|
|
549
|
+
Fixes #8131
|
|
302
550
|
|
|
303
|
-
-
|
|
551
|
+
- Added `flush()` method to `ObservabilityExporter`, `ObservabilityBridge`, and `ObservabilityInstance` interfaces ([#12003](https://github.com/mastra-ai/mastra/pull/12003))
|
|
304
552
|
|
|
305
|
-
-
|
|
553
|
+
- Add `hideInput` and `hideOutput` options to `TracingOptions` for protecting sensitive data in traces. ([#11969](https://github.com/mastra-ai/mastra/pull/11969))
|
|
306
554
|
|
|
307
|
-
|
|
555
|
+
When set to `true`, these options hide input/output data from all spans in a trace, including child spans. This is useful for protecting sensitive information from being logged to observability platforms.
|
|
308
556
|
|
|
309
|
-
|
|
557
|
+
```typescript
|
|
558
|
+
const agent = mastra.getAgent('myAgent');
|
|
559
|
+
await agent.generate('Process this sensitive data', {
|
|
560
|
+
tracingOptions: {
|
|
561
|
+
hideInput: true, // Input will be hidden from all spans
|
|
562
|
+
hideOutput: true, // Output will be hidden from all spans
|
|
563
|
+
},
|
|
564
|
+
});
|
|
565
|
+
```
|
|
310
566
|
|
|
311
|
-
|
|
567
|
+
The options can be used independently (hide only input or only output) or together. The settings are propagated to all child spans via `TraceState`, ensuring consistent behavior across the entire trace.
|
|
312
568
|
|
|
313
|
-
|
|
569
|
+
Fixes #10888
|
|
314
570
|
|
|
315
|
-
|
|
571
|
+
- Add `onError` hook to server configuration for custom error handling. ([#11403](https://github.com/mastra-ai/mastra/pull/11403))
|
|
316
572
|
|
|
317
|
-
|
|
573
|
+
You can now provide a custom error handler through the Mastra server config to catch errors, format responses, or send them to external services like Sentry:
|
|
318
574
|
|
|
319
|
-
|
|
575
|
+
```typescript
|
|
576
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
577
|
+
|
|
578
|
+
const mastra = new Mastra({
|
|
579
|
+
server: {
|
|
580
|
+
onError: (err, c) => {
|
|
581
|
+
// Send to Sentry
|
|
582
|
+
Sentry.captureException(err);
|
|
583
|
+
|
|
584
|
+
// Return custom formatted response
|
|
585
|
+
return c.json(
|
|
586
|
+
{
|
|
587
|
+
error: err.message,
|
|
588
|
+
timestamp: new Date().toISOString(),
|
|
589
|
+
},
|
|
590
|
+
500,
|
|
591
|
+
);
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
});
|
|
595
|
+
```
|
|
320
596
|
|
|
321
|
-
|
|
597
|
+
If no `onError` is provided, the default error handler is used.
|
|
322
598
|
|
|
323
|
-
|
|
599
|
+
Fixes #9610
|
|
324
600
|
|
|
325
|
-
-
|
|
601
|
+
- Add stored agents support ([#10953](https://github.com/mastra-ai/mastra/pull/10953))
|
|
326
602
|
|
|
327
|
-
|
|
603
|
+
Agents can now be stored in the database and loaded at runtime. This lets you persist agent configurations and dynamically create executable Agent instances from storage.
|
|
328
604
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
- `agent-legacy.ts` - `AgentLegacyCapabilities` interface
|
|
605
|
+
```typescript
|
|
606
|
+
import { Mastra } from '@mastra/core';
|
|
607
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
333
608
|
|
|
334
|
-
|
|
609
|
+
const mastra = new Mastra({
|
|
610
|
+
storage: new LibSQLStore({ url: ':memory:' }),
|
|
611
|
+
tools: { myTool },
|
|
612
|
+
scorers: { myScorer },
|
|
613
|
+
});
|
|
335
614
|
|
|
336
|
-
|
|
615
|
+
// Create agent in storage via API or directly
|
|
616
|
+
await mastra.getStorage().createAgent({
|
|
617
|
+
agent: {
|
|
618
|
+
id: 'my-agent',
|
|
619
|
+
name: 'My Agent',
|
|
620
|
+
instructions: 'You are helpful',
|
|
621
|
+
model: { provider: 'openai', name: 'gpt-4' },
|
|
622
|
+
tools: { myTool: {} },
|
|
623
|
+
scorers: { myScorer: { sampling: { type: 'ratio', rate: 0.5 } } },
|
|
624
|
+
},
|
|
625
|
+
});
|
|
337
626
|
|
|
338
|
-
|
|
627
|
+
// Load and use the agent
|
|
628
|
+
const agent = await mastra.getStoredAgentById('my-agent');
|
|
629
|
+
const response = await agent.generate('Hello!');
|
|
339
630
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
631
|
+
// List all stored agents with pagination
|
|
632
|
+
const { agents, total, hasMore } = await mastra.listStoredAgents({
|
|
633
|
+
page: 0,
|
|
634
|
+
perPage: 10,
|
|
635
|
+
});
|
|
343
636
|
```
|
|
344
637
|
|
|
345
|
-
|
|
638
|
+
Also adds a memory registry to Mastra so stored agents can reference memory instances by key.
|
|
346
639
|
|
|
640
|
+
- Added human-in-the-loop (HITL) tool approval support for `generate()` method. ([#12056](https://github.com/mastra-ai/mastra/pull/12056))
|
|
641
|
+
|
|
642
|
+
**Why:** This provides parity between `stream()` and `generate()` for tool approval flows, allowing non-streaming use cases to leverage `requireToolApproval` without needing to switch to streaming.
|
|
643
|
+
|
|
644
|
+
Previously, tool approval with `requireToolApproval` only worked with `stream()`. Now you can use the same approval flow with `generate()` for non-streaming use cases.
|
|
645
|
+
|
|
646
|
+
**Using tool approval with generate()**
|
|
647
|
+
|
|
648
|
+
```typescript
|
|
649
|
+
const output = await agent.generate('Find user John', {
|
|
650
|
+
requireToolApproval: true,
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
// Check if a tool is waiting for approval
|
|
654
|
+
if (output.finishReason === 'suspended') {
|
|
655
|
+
console.log('Tool requires approval:', output.suspendPayload.toolName);
|
|
656
|
+
|
|
657
|
+
// Approve the tool call
|
|
658
|
+
const result = await agent.approveToolCallGenerate({
|
|
659
|
+
runId: output.runId,
|
|
660
|
+
toolCallId: output.suspendPayload.toolCallId,
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
console.log(result.text);
|
|
664
|
+
}
|
|
347
665
|
```
|
|
348
|
-
|
|
349
|
-
|
|
666
|
+
|
|
667
|
+
**Declining a tool call**
|
|
668
|
+
|
|
669
|
+
```typescript
|
|
670
|
+
if (output.finishReason === 'suspended') {
|
|
671
|
+
const result = await agent.declineToolCallGenerate({
|
|
672
|
+
runId: output.runId,
|
|
673
|
+
toolCallId: output.suspendPayload.toolCallId,
|
|
674
|
+
});
|
|
675
|
+
}
|
|
350
676
|
```
|
|
351
677
|
|
|
352
|
-
|
|
678
|
+
**New methods added:**
|
|
679
|
+
- `agent.approveToolCallGenerate({ runId, toolCallId })` - Approves a pending tool call and returns the complete result
|
|
680
|
+
- `agent.declineToolCallGenerate({ runId, toolCallId })` - Declines a pending tool call and returns the complete result
|
|
353
681
|
|
|
354
|
-
|
|
682
|
+
**Server routes added:**
|
|
683
|
+
- `POST /api/agents/:agentId/approve-tool-call-generate`
|
|
684
|
+
- `POST /api/agents/:agentId/decline-tool-call-generate`
|
|
355
685
|
|
|
356
|
-
|
|
686
|
+
The playground UI now also supports tool approval when using generate mode.
|
|
357
687
|
|
|
358
|
-
|
|
688
|
+
- Memory system now uses processors. Memory processors (`MessageHistory`, `SemanticRecall`, `WorkingMemory`) are now exported from `@mastra/memory/processors` and automatically added to the agent pipeline based on your memory config. Core processors (`ToolCallFilter`, `TokenLimiter`) remain in `@mastra/core/processors`. ([#9254](https://github.com/mastra-ai/mastra/pull/9254))
|
|
359
689
|
|
|
360
|
-
-
|
|
690
|
+
- Add reserved keys in RequestContext for secure resourceId/threadId setting from middleware ([#10657](https://github.com/mastra-ai/mastra/pull/10657))
|
|
361
691
|
|
|
362
|
-
|
|
692
|
+
This allows middleware to securely set `resourceId` and `threadId` via reserved keys in RequestContext (`MASTRA_RESOURCE_ID_KEY` and `MASTRA_THREAD_ID_KEY`), which take precedence over client-provided values for security.
|
|
363
693
|
|
|
364
|
-
-
|
|
694
|
+
- Removed the deprecated `AISDKV5OutputStream` class from the public API. ([#11845](https://github.com/mastra-ai/mastra/pull/11845))
|
|
365
695
|
|
|
366
|
-
This
|
|
696
|
+
**What changed:** The `AISDKV5OutputStream` class is no longer exported from `@mastra/core`. This class was previously used with the `format: 'aisdk'` option, which has already been removed from `.stream()` and `.generate()` methods.
|
|
697
|
+
|
|
698
|
+
**Who is affected:** Only users who were directly importing `AISDKV5OutputStream` from `@mastra/core`. If you were using the standard `.stream()` or `.generate()` methods without the `format` option, no changes are needed.
|
|
699
|
+
|
|
700
|
+
**Migration:** If you were importing this class directly, switch to using `MastraModelOutput` which provides the same streaming functionality:
|
|
367
701
|
|
|
368
702
|
```typescript
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
703
|
+
// Before
|
|
704
|
+
import { AISDKV5OutputStream } from '@mastra/core';
|
|
705
|
+
|
|
706
|
+
// After
|
|
707
|
+
import { MastraModelOutput } from '@mastra/core';
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
- Changed JSON columns from TEXT to JSONB in `mastra_threads` and `mastra_workflow_snapshot` tables. ([#11853](https://github.com/mastra-ai/mastra/pull/11853))
|
|
711
|
+
|
|
712
|
+
**Why this change?**
|
|
713
|
+
|
|
714
|
+
These were the last remaining columns storing JSON as TEXT. This change aligns them with other tables that already use JSONB, enabling native JSON operators and improved performance. See [#8978](https://github.com/mastra-ai/mastra/issues/8978) for details.
|
|
715
|
+
|
|
716
|
+
**Columns Changed:**
|
|
717
|
+
- `mastra_threads.metadata` - Thread metadata
|
|
718
|
+
- `mastra_workflow_snapshot.snapshot` - Workflow run state
|
|
719
|
+
|
|
720
|
+
**PostgreSQL**
|
|
721
|
+
|
|
722
|
+
Migration Required - PostgreSQL enforces column types, so existing tables must be migrated. Note: Migration will fail if existing column values contain invalid JSON.
|
|
723
|
+
|
|
724
|
+
```sql
|
|
725
|
+
ALTER TABLE mastra_threads
|
|
726
|
+
ALTER COLUMN metadata TYPE jsonb
|
|
727
|
+
USING metadata::jsonb;
|
|
728
|
+
|
|
729
|
+
ALTER TABLE mastra_workflow_snapshot
|
|
730
|
+
ALTER COLUMN snapshot TYPE jsonb
|
|
731
|
+
USING snapshot::jsonb;
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
**LibSQL**
|
|
735
|
+
|
|
736
|
+
No Migration Required - LibSQL now uses native SQLite JSONB format (added in SQLite 3.45) for ~3x performance improvement on JSON operations. The changes are fully backwards compatible:
|
|
737
|
+
- Existing TEXT JSON data continues to work
|
|
738
|
+
- New data is stored in binary JSONB format
|
|
739
|
+
- Both formats can coexist in the same table
|
|
740
|
+
- All JSON functions (`json_extract`, etc.) work on both formats
|
|
741
|
+
|
|
742
|
+
New installations automatically use JSONB. Existing applications continue to work without any changes.
|
|
743
|
+
|
|
744
|
+
- Memory scope defaults changed from 'thread' to 'resource' ([#8983](https://github.com/mastra-ai/mastra/pull/8983))
|
|
745
|
+
|
|
746
|
+
Both `workingMemory.scope` and `semanticRecall.scope` now default to `'resource'` instead of `'thread'`. This means:
|
|
747
|
+
- Working memory persists across all conversations for the same user/resource
|
|
748
|
+
- Semantic recall searches across all threads for the same user/resource
|
|
749
|
+
|
|
750
|
+
**Migration**: To maintain the previous thread-scoped behavior, explicitly set `scope: 'thread'`:
|
|
751
|
+
|
|
752
|
+
```typescript
|
|
753
|
+
memory: new Memory({
|
|
754
|
+
storage,
|
|
755
|
+
workingMemory: {
|
|
756
|
+
enabled: true,
|
|
757
|
+
scope: 'thread', // Explicitly set for thread-scoped behavior
|
|
758
|
+
},
|
|
759
|
+
semanticRecall: {
|
|
760
|
+
scope: 'thread', // Explicitly set for thread-scoped behavior
|
|
761
|
+
},
|
|
762
|
+
}),
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
Also fixed issues where playground semantic recall search could show missing or incorrect results in certain cases.
|
|
766
|
+
|
|
767
|
+
- Add support for AI SDK v6 (LanguageModelV3) ([#11191](https://github.com/mastra-ai/mastra/pull/11191))
|
|
768
|
+
|
|
769
|
+
Agents can now use `LanguageModelV3` models from AI SDK v6 beta providers like `@ai-sdk/openai@^3.0.0-beta`.
|
|
770
|
+
|
|
771
|
+
**New features:**
|
|
772
|
+
- Usage normalization: V3's nested usage format is normalized to Mastra's flat format with `reasoningTokens`, `cachedInputTokens`, and raw data preserved in a `raw` field
|
|
773
|
+
|
|
774
|
+
**Backward compatible:** All existing V1 and V2 models continue to work unchanged.
|
|
775
|
+
|
|
776
|
+
- Respect structured outputs for v2 models so tool schemas aren’t stripped ([#11038](https://github.com/mastra-ai/mastra/pull/11038))
|
|
777
|
+
|
|
778
|
+
- Deprecate `default: { enabled: true }` observability configuration ([#11674](https://github.com/mastra-ai/mastra/pull/11674))
|
|
779
|
+
|
|
780
|
+
The shorthand `default: { enabled: true }` configuration is now deprecated and will be removed in a future version. Users should migrate to explicit configuration with `DefaultExporter`, `CloudExporter`, and `SensitiveDataFilter`.
|
|
781
|
+
|
|
782
|
+
**Before (deprecated):**
|
|
783
|
+
|
|
784
|
+
```typescript
|
|
785
|
+
import { Observability } from '@mastra/observability';
|
|
786
|
+
|
|
787
|
+
const mastra = new Mastra({
|
|
788
|
+
observability: new Observability({
|
|
789
|
+
default: { enabled: true },
|
|
790
|
+
}),
|
|
791
|
+
});
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
**After (recommended):**
|
|
795
|
+
|
|
796
|
+
```typescript
|
|
797
|
+
import { Observability, DefaultExporter, CloudExporter, SensitiveDataFilter } from '@mastra/observability';
|
|
798
|
+
|
|
799
|
+
const mastra = new Mastra({
|
|
800
|
+
observability: new Observability({
|
|
801
|
+
configs: {
|
|
802
|
+
default: {
|
|
803
|
+
serviceName: 'mastra',
|
|
804
|
+
exporters: [new DefaultExporter(), new CloudExporter()],
|
|
805
|
+
spanOutputProcessors: [new SensitiveDataFilter()],
|
|
806
|
+
},
|
|
376
807
|
},
|
|
808
|
+
}),
|
|
809
|
+
});
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
The explicit configuration makes it clear exactly what exporters and processors are being used, improving code readability and maintainability.
|
|
813
|
+
|
|
814
|
+
A deprecation warning will be logged when using the old configuration pattern.
|
|
815
|
+
|
|
816
|
+
- Exported `isProcessorWorkflow` function from @mastra/core/processors. Added `getConfiguredProcessorWorkflows()` method to agents and `listProcessors()` method to the Mastra class for programmatic access to processor information. ([#12059](https://github.com/mastra-ai/mastra/pull/12059))
|
|
817
|
+
|
|
818
|
+
- Adds a new `suspendData` parameter to workflow step execute functions that provides access to the data originally passed to `suspend()` when the step was suspended. This enables steps to access context about why they were suspended when they are later resumed. ([#10734](https://github.com/mastra-ai/mastra/pull/10734))
|
|
819
|
+
|
|
820
|
+
**New Features:**
|
|
821
|
+
- `suspendData` parameter automatically populated in step execute function when resuming
|
|
822
|
+
- Type-safe access to suspend data matching the step's `suspendSchema`
|
|
823
|
+
- Backward compatible - existing workflows continue to work unchanged
|
|
824
|
+
|
|
825
|
+
**Example:**
|
|
826
|
+
|
|
827
|
+
```typescript
|
|
828
|
+
const step = createStep({
|
|
829
|
+
suspendSchema: z.object({ reason: z.string() }),
|
|
830
|
+
resumeSchema: z.object({ approved: z.boolean() }),
|
|
831
|
+
execute: async ({ suspend, suspendData, resumeData }) => {
|
|
832
|
+
if (!resumeData?.approved) {
|
|
833
|
+
return await suspend({ reason: 'Approval required' });
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// Access original suspend data when resuming
|
|
837
|
+
console.log(`Resuming after: ${suspendData?.reason}`);
|
|
838
|
+
return { result: 'Approved' };
|
|
377
839
|
},
|
|
378
840
|
});
|
|
379
841
|
```
|
|
380
842
|
|
|
381
|
-
-
|
|
843
|
+
- - Fixed TypeScript errors where `threadId: string | string[]` was being passed to places expecting `Scalar` type ([#10663](https://github.com/mastra-ai/mastra/pull/10663))
|
|
844
|
+
- Added proper multi-thread support for `listMessages` across all adapters when `threadId` is an array
|
|
845
|
+
- Updated `_getIncludedMessages` to look up message threadId by ID (since message IDs are globally unique)
|
|
846
|
+
- **upstash**: Added `msg-idx:{messageId}` index for O(1) message lookups (backwards compatible with fallback to scan for old messages, with automatic backfill)
|
|
382
847
|
|
|
383
|
-
-
|
|
848
|
+
- Added `TrackingExporter` base class with improved handling for: ([#11870](https://github.com/mastra-ai/mastra/pull/11870))
|
|
849
|
+
- **Out-of-order span processing**: Spans that arrive before their parents are now queued and processed once dependencies are available
|
|
850
|
+
- **Delayed cleanup**: Trace data is retained briefly after spans end to handle late-arriving updates
|
|
851
|
+
- **Memory management**: Configurable limits on pending and total traces to prevent memory leaks
|
|
384
852
|
|
|
385
|
-
|
|
853
|
+
New configuration options on `TrackingExporterConfig`:
|
|
854
|
+
- `earlyQueueMaxAttempts` - Max retry attempts for queued events (default: 5)
|
|
855
|
+
- `earlyQueueTTLMs` - TTL for queued events in ms (default: 30000)
|
|
856
|
+
- `traceCleanupDelayMs` - Delay before cleaning up completed traces (default: 30000)
|
|
857
|
+
- `maxPendingCleanupTraces` - Soft cap on traces awaiting cleanup (default: 100)
|
|
858
|
+
- `maxTotalTraces` - Hard cap on total traces (default: 500)
|
|
386
859
|
|
|
387
|
-
|
|
860
|
+
Updated @mastra/braintrust, @mastra/langfuse, @mastra/langsmith, @mastra/posthog to use the new TrackingExporter
|
|
388
861
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
862
|
+
- Introduce StorageDomain base class for composite storage support ([#11249](https://github.com/mastra-ai/mastra/pull/11249))
|
|
863
|
+
|
|
864
|
+
Storage adapters now use a domain-based architecture where each domain (memory, workflows, scores, observability, agents) extends a `StorageDomain` base class with `init()` and `dangerouslyClearAll()` methods.
|
|
865
|
+
|
|
866
|
+
**Key changes:**
|
|
867
|
+
- Add `StorageDomain` abstract base class that all domain storage classes extend
|
|
868
|
+
- Add `InMemoryDB` class for shared state across in-memory domain implementations
|
|
869
|
+
- All storage domains now implement `dangerouslyClearAll()` for test cleanup
|
|
870
|
+
- Remove `operations` from public `StorageDomains` type (now internal to each adapter)
|
|
871
|
+
- Add flexible client/config patterns - domains accept either an existing database client or config to create one internally
|
|
872
|
+
|
|
873
|
+
**Why this matters:**
|
|
874
|
+
|
|
875
|
+
This enables composite storage where you can use different database adapters per domain:
|
|
876
|
+
|
|
877
|
+
```typescript
|
|
878
|
+
import { Mastra } from '@mastra/core';
|
|
879
|
+
import { PostgresStore } from '@mastra/pg';
|
|
880
|
+
import { ClickhouseStore } from '@mastra/clickhouse';
|
|
881
|
+
|
|
882
|
+
// Use Postgres for most domains but Clickhouse for observability
|
|
883
|
+
const mastra = new Mastra({
|
|
884
|
+
storage: new PostgresStore({
|
|
885
|
+
connectionString: 'postgres://...',
|
|
886
|
+
}),
|
|
887
|
+
// Future: override specific domains
|
|
888
|
+
// observability: new ClickhouseStore({ ... }).getStore('observability'),
|
|
889
|
+
});
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
**Standalone domain usage:**
|
|
893
|
+
|
|
894
|
+
Domains can now be used independently with flexible configuration:
|
|
895
|
+
|
|
896
|
+
```typescript
|
|
897
|
+
import { MemoryLibSQL } from '@mastra/libsql/memory';
|
|
898
|
+
|
|
899
|
+
// Option 1: Pass config to create client internally
|
|
900
|
+
const memory = new MemoryLibSQL({
|
|
901
|
+
url: 'file:./local.db',
|
|
902
|
+
});
|
|
903
|
+
|
|
904
|
+
// Option 2: Pass existing client for shared connections
|
|
905
|
+
import { createClient } from '@libsql/client';
|
|
906
|
+
const client = createClient({ url: 'file:./local.db' });
|
|
907
|
+
const memory = new MemoryLibSQL({ client });
|
|
908
|
+
```
|
|
909
|
+
|
|
910
|
+
**Breaking changes:**
|
|
911
|
+
- `StorageDomains` type no longer includes `operations` - access via `getStore()` instead
|
|
912
|
+
- Domain base classes now require implementing `dangerouslyClearAll()` method
|
|
913
|
+
|
|
914
|
+
- Refactor storage architecture to use domain-specific stores via `getStore()` pattern ([#11361](https://github.com/mastra-ai/mastra/pull/11361))
|
|
915
|
+
|
|
916
|
+
### Summary
|
|
917
|
+
|
|
918
|
+
This release introduces a new storage architecture that replaces passthrough methods on `MastraStorage` with domain-specific storage interfaces accessed via `getStore()`. This change reduces code duplication across storage adapters and provides a cleaner, more modular API.
|
|
919
|
+
|
|
920
|
+
### Migration Guide
|
|
921
|
+
|
|
922
|
+
All direct method calls on storage instances should be updated to use `getStore()`:
|
|
923
|
+
|
|
924
|
+
```typescript
|
|
925
|
+
// Before
|
|
926
|
+
const thread = await storage.getThreadById({ threadId });
|
|
927
|
+
await storage.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
928
|
+
await storage.createSpan(span);
|
|
929
|
+
|
|
930
|
+
// After
|
|
931
|
+
const memory = await storage.getStore('memory');
|
|
932
|
+
const thread = await memory?.getThreadById({ threadId });
|
|
933
|
+
|
|
934
|
+
const workflows = await storage.getStore('workflows');
|
|
935
|
+
await workflows?.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
936
|
+
|
|
937
|
+
const observability = await storage.getStore('observability');
|
|
938
|
+
await observability?.createSpan(span);
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
### Available Domains
|
|
942
|
+
- **`memory`**: Thread and message operations (`getThreadById`, `saveThread`, `saveMessages`, etc.)
|
|
943
|
+
- **`workflows`**: Workflow state persistence (`persistWorkflowSnapshot`, `loadWorkflowSnapshot`, `getWorkflowRunById`, etc.)
|
|
944
|
+
- **`scores`**: Evaluation scores (`saveScore`, `listScoresByScorerId`, etc.)
|
|
945
|
+
- **`observability`**: Tracing and spans (`createSpan`, `updateSpan`, `getTrace`, etc.)
|
|
946
|
+
- **`agents`**: Stored agent configurations (`createAgent`, `getAgentById`, `listAgents`, etc.)
|
|
947
|
+
|
|
948
|
+
### Breaking Changes
|
|
949
|
+
- Passthrough methods have been removed from `MastraStorage` base class
|
|
950
|
+
- All storage adapters now require accessing domains via `getStore()`
|
|
951
|
+
- The `stores` property on storage instances is now the canonical way to access domain storage
|
|
952
|
+
|
|
953
|
+
### Internal Changes
|
|
954
|
+
- Each storage adapter now initializes domain-specific stores in its constructor
|
|
955
|
+
- Domain stores share database connections and handle their own table initialization
|
|
956
|
+
|
|
957
|
+
- Adds trace tagging support to the BrainTrust and Langfuse tracing exporters. ([#10765](https://github.com/mastra-ai/mastra/pull/10765))
|
|
958
|
+
|
|
959
|
+
- Add support for AI SDK v6 ToolLoopAgent in Mastra ([#11254](https://github.com/mastra-ai/mastra/pull/11254))
|
|
960
|
+
|
|
961
|
+
You can now pass an AI SDK v6 `ToolLoopAgent` directly to Mastra's agents configuration. The agent will be automatically converted to a Mastra Agent while preserving all ToolLoopAgent lifecycle hooks:
|
|
962
|
+
- `prepareCall` - Called once at the start of generate/stream
|
|
963
|
+
- `prepareStep` - Called before each step in the agentic loop
|
|
964
|
+
- `stopWhen` - Custom stop conditions for the loop
|
|
965
|
+
|
|
966
|
+
Example:
|
|
967
|
+
|
|
968
|
+
```typescript
|
|
969
|
+
import { ToolLoopAgent } from 'ai';
|
|
970
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
971
|
+
|
|
972
|
+
const toolLoopAgent = new ToolLoopAgent({
|
|
973
|
+
model: openai('gpt-4o'),
|
|
974
|
+
instructions: 'You are a helpful assistant.',
|
|
975
|
+
tools: { weather: weatherTool },
|
|
976
|
+
prepareStep: async ({ stepNumber }) => {
|
|
977
|
+
if (stepNumber === 0) {
|
|
978
|
+
return { toolChoice: 'required' };
|
|
979
|
+
}
|
|
395
980
|
},
|
|
396
|
-
};
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
const mastra = new Mastra({
|
|
984
|
+
agents: { toolLoopAgent },
|
|
985
|
+
});
|
|
986
|
+
|
|
987
|
+
// Use like any other Mastra agent
|
|
988
|
+
const agent = mastra.getAgent('toolLoopAgent');
|
|
989
|
+
const result = await agent.generate('What is the weather?');
|
|
397
990
|
```
|
|
398
991
|
|
|
399
|
-
-
|
|
992
|
+
- Unified observability schema with entity-based span identification ([#11132](https://github.com/mastra-ai/mastra/pull/11132))
|
|
993
|
+
|
|
994
|
+
## What changed
|
|
995
|
+
|
|
996
|
+
Spans now use a unified identification model with `entityId`, `entityType`, and `entityName` instead of separate `agentId`, `toolId`, `workflowId` fields.
|
|
400
997
|
|
|
401
998
|
**Before:**
|
|
402
999
|
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
1000
|
+
```typescript
|
|
1001
|
+
// Old span structure
|
|
1002
|
+
span.agentId; // 'my-agent'
|
|
1003
|
+
span.toolId; // undefined
|
|
1004
|
+
span.workflowId; // undefined
|
|
407
1005
|
```
|
|
408
1006
|
|
|
409
1007
|
**After:**
|
|
410
1008
|
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
|
|
1009
|
+
```typescript
|
|
1010
|
+
// New span structure
|
|
1011
|
+
span.entityType; // EntityType.AGENT
|
|
1012
|
+
span.entityId; // 'my-agent'
|
|
1013
|
+
span.entityName; // 'My Agent'
|
|
414
1014
|
```
|
|
415
1015
|
|
|
416
|
-
|
|
1016
|
+
## New `listTraces()` API
|
|
417
1017
|
|
|
418
|
-
|
|
419
|
-
Also fixes requestContext persistence by relying on inngest step memoization.
|
|
1018
|
+
Query traces with filtering, pagination, and sorting:
|
|
420
1019
|
|
|
421
|
-
|
|
1020
|
+
```typescript
|
|
1021
|
+
const { spans, pagination } = await storage.listTraces({
|
|
1022
|
+
filters: {
|
|
1023
|
+
entityType: EntityType.AGENT,
|
|
1024
|
+
entityId: 'my-agent',
|
|
1025
|
+
userId: 'user-123',
|
|
1026
|
+
environment: 'production',
|
|
1027
|
+
status: TraceStatus.SUCCESS,
|
|
1028
|
+
startedAt: { start: new Date('2024-01-01'), end: new Date('2024-01-31') },
|
|
1029
|
+
},
|
|
1030
|
+
pagination: { page: 0, perPage: 50 },
|
|
1031
|
+
orderBy: { field: 'startedAt', direction: 'DESC' },
|
|
1032
|
+
});
|
|
1033
|
+
```
|
|
422
1034
|
|
|
423
|
-
|
|
1035
|
+
**Available filters:** date ranges (`startedAt`, `endedAt`), entity (`entityType`, `entityId`, `entityName`), identity (`userId`, `organizationId`), correlation IDs (`runId`, `sessionId`, `threadId`), deployment (`environment`, `source`, `serviceName`), `tags`, `metadata`, and `status`.
|
|
424
1036
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
1037
|
+
## New retrieval methods
|
|
1038
|
+
- `getSpan({ traceId, spanId })` - Get a single span
|
|
1039
|
+
- `getRootSpan({ traceId })` - Get the root span of a trace
|
|
1040
|
+
- `getTrace({ traceId })` - Get all spans for a trace
|
|
428
1041
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
1042
|
+
## Backward compatibility
|
|
1043
|
+
|
|
1044
|
+
The legacy `getTraces()` method continues to work. When you pass `name: "agent run: my-agent"`, it automatically transforms to `entityId: "my-agent", entityType: AGENT`.
|
|
1045
|
+
|
|
1046
|
+
## Migration
|
|
1047
|
+
|
|
1048
|
+
**Automatic:** SQL-based stores (PostgreSQL, LibSQL, MSSQL) automatically add new columns to existing `spans` tables on initialization. Existing data is preserved with new columns set to `NULL`.
|
|
1049
|
+
|
|
1050
|
+
**No action required:** Your existing code continues to work. Adopt the new fields and `listTraces()` API at your convenience.
|
|
1051
|
+
|
|
1052
|
+
- Add embedderOptions support to Memory for AI SDK 5+ provider-specific embedding options ([#11462](https://github.com/mastra-ai/mastra/pull/11462))
|
|
1053
|
+
|
|
1054
|
+
With AI SDK 5+, embedding models no longer accept options in their constructor. Options like `outputDimensionality` for Google embedding models must now be passed when calling `embed()` or `embedMany()`. This change adds `embedderOptions` to Memory configuration to enable passing these provider-specific options.
|
|
1055
|
+
|
|
1056
|
+
You can now configure embedder options when creating Memory:
|
|
1057
|
+
|
|
1058
|
+
```typescript
|
|
1059
|
+
import { Memory } from '@mastra/core';
|
|
1060
|
+
import { google } from '@ai-sdk/google';
|
|
1061
|
+
|
|
1062
|
+
// Before: No way to specify providerOptions
|
|
1063
|
+
const memory = new Memory({
|
|
1064
|
+
embedder: google.textEmbeddingModel('text-embedding-004'),
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
// After: Pass embedderOptions with providerOptions
|
|
1068
|
+
const memory = new Memory({
|
|
1069
|
+
embedder: google.textEmbeddingModel('text-embedding-004'),
|
|
1070
|
+
embedderOptions: {
|
|
1071
|
+
providerOptions: {
|
|
1072
|
+
google: {
|
|
1073
|
+
outputDimensionality: 768,
|
|
1074
|
+
taskType: 'RETRIEVAL_DOCUMENT',
|
|
1075
|
+
},
|
|
1076
|
+
},
|
|
1077
|
+
},
|
|
1078
|
+
});
|
|
432
1079
|
```
|
|
433
1080
|
|
|
434
|
-
|
|
435
|
-
-
|
|
436
|
-
-
|
|
437
|
-
- Server adapters now auto-register with Mastra in their constructor
|
|
1081
|
+
This is especially important for:
|
|
1082
|
+
- Google `text-embedding-004`: Control output dimensions (default 768)
|
|
1083
|
+
- Google `gemini-embedding-001`: Reduce from default 3072 dimensions to avoid pgvector's 2000 dimension limit for HNSW indexes
|
|
438
1084
|
|
|
439
|
-
|
|
1085
|
+
Fixes #8248
|
|
440
1086
|
|
|
441
|
-
-
|
|
1087
|
+
- Add `messageList` parameter to `processOutputStream` for accessing remembered messages during streaming ([#10608](https://github.com/mastra-ai/mastra/pull/10608))
|
|
442
1088
|
|
|
443
|
-
- Fix
|
|
1089
|
+
- Fix processor tracing to create individual spans per processor ([#11683](https://github.com/mastra-ai/mastra/pull/11683))
|
|
1090
|
+
- Processor spans now correctly show processor IDs (e.g., `input processor: validator`) instead of combined workflow IDs
|
|
1091
|
+
- Each processor in a chain gets its own trace span, improving observability into processor execution
|
|
1092
|
+
- Spans are only created for phases a processor actually implements, eliminating empty spans
|
|
1093
|
+
- Internal agent calls within processors now properly nest under their processor span
|
|
1094
|
+
- Added `INPUT_STEP_PROCESSOR` and `OUTPUT_STEP_PROCESSOR` entity types for finer-grained tracing
|
|
1095
|
+
- Changed `processorType` span attribute to `processorExecutor` with values `'workflow'` or `'legacy'`
|
|
444
1096
|
|
|
445
|
-
|
|
1097
|
+
- Added a unified `transformScoreRow` function in `@mastra/core/storage` that provides schema-driven row transformation for score data. This eliminates code duplication across 10 storage adapters while maintaining store-specific behavior through configurable options: ([#10648](https://github.com/mastra-ai/mastra/pull/10648))
|
|
1098
|
+
- `preferredTimestampFields`: Preferred source fields for timestamps (PostgreSQL, Cloudflare D1)
|
|
1099
|
+
- `convertTimestamps`: Convert timestamp strings to Date objects (MSSQL, MongoDB, ClickHouse)
|
|
1100
|
+
- `nullValuePattern`: Skip values matching pattern (ClickHouse's `'_null_'`)
|
|
1101
|
+
- `fieldMappings`: Map source column names to schema fields (LibSQL's `additionalLLMContext`)
|
|
446
1102
|
|
|
447
|
-
|
|
1103
|
+
Each store adapter now uses the unified function with appropriate options, reducing ~200 lines of duplicate transformation logic while ensuring consistent behavior across all storage backends.
|
|
448
1104
|
|
|
449
|
-
-
|
|
1105
|
+
- Added new `listThreads` method for flexible thread filtering across all storage adapters. ([#11832](https://github.com/mastra-ai/mastra/pull/11832))
|
|
450
1106
|
|
|
451
|
-
|
|
1107
|
+
**New Features**
|
|
1108
|
+
- Filter threads by `resourceId`, `metadata`, or both (with AND logic for metadata key-value pairs)
|
|
1109
|
+
- All filter parameters are optional, allowing you to list all threads or filter as needed
|
|
1110
|
+
- Full pagination and sorting support
|
|
452
1111
|
|
|
453
|
-
|
|
1112
|
+
**Example Usage**
|
|
454
1113
|
|
|
455
1114
|
```typescript
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
1115
|
+
// List all threads
|
|
1116
|
+
const allThreads = await memory.listThreads({});
|
|
1117
|
+
|
|
1118
|
+
// Filter by resourceId only
|
|
1119
|
+
const userThreads = await memory.listThreads({
|
|
1120
|
+
filter: { resourceId: 'user-123' },
|
|
1121
|
+
});
|
|
1122
|
+
|
|
1123
|
+
// Filter by metadata only
|
|
1124
|
+
const supportThreads = await memory.listThreads({
|
|
1125
|
+
filter: { metadata: { category: 'support' } },
|
|
1126
|
+
});
|
|
1127
|
+
|
|
1128
|
+
// Filter by both with pagination
|
|
1129
|
+
const filteredThreads = await memory.listThreads({
|
|
1130
|
+
filter: {
|
|
1131
|
+
resourceId: 'user-123',
|
|
1132
|
+
metadata: { priority: 'high', status: 'open' },
|
|
460
1133
|
},
|
|
461
|
-
|
|
1134
|
+
orderBy: { field: 'updatedAt', direction: 'DESC' },
|
|
1135
|
+
page: 0,
|
|
1136
|
+
perPage: 20,
|
|
462
1137
|
});
|
|
463
1138
|
```
|
|
464
1139
|
|
|
465
|
-
|
|
1140
|
+
**Security Improvements**
|
|
1141
|
+
- Added validation to prevent SQL injection via malicious metadata keys
|
|
1142
|
+
- Added pagination parameter validation to prevent integer overflow attacks
|
|
466
1143
|
|
|
467
|
-
-
|
|
468
|
-
- @mastra/observability@1.0.0-beta.2
|
|
469
|
-
- @mastra/schema-compat@1.0.0-beta.2
|
|
1144
|
+
- Add completion validation to agent networks using custom scorers ([#11562](https://github.com/mastra-ai/mastra/pull/11562))
|
|
470
1145
|
|
|
471
|
-
|
|
1146
|
+
You can now validate whether an agent network has completed its task by passing MastraScorers to `agent.network()`. When validation fails, the network automatically retries with feedback injected into the conversation.
|
|
472
1147
|
|
|
473
|
-
|
|
1148
|
+
**Example: Creating a scorer to verify test coverage**
|
|
474
1149
|
|
|
475
|
-
|
|
1150
|
+
```ts
|
|
1151
|
+
import { createScorer } from '@mastra/core/evals';
|
|
1152
|
+
import { z } from 'zod';
|
|
1153
|
+
|
|
1154
|
+
// Create a scorer that checks if tests were written
|
|
1155
|
+
const testsScorer = createScorer({
|
|
1156
|
+
id: 'tests-written',
|
|
1157
|
+
description: 'Validates that unit tests were included in the response',
|
|
1158
|
+
type: 'agent',
|
|
1159
|
+
}).generateScore({
|
|
1160
|
+
description: 'Return 1 if tests are present, 0 if missing',
|
|
1161
|
+
outputSchema: z.number(),
|
|
1162
|
+
createPrompt: ({ run }) => `
|
|
1163
|
+
Does this response include unit tests?
|
|
1164
|
+
Response: ${run.output}
|
|
1165
|
+
Return 1 if tests are present, 0 if not.
|
|
1166
|
+
`,
|
|
1167
|
+
});
|
|
476
1168
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
1169
|
+
// Use the scorer with agent.network()
|
|
1170
|
+
const stream = await agent.network('Implement a fibonacci function with tests', {
|
|
1171
|
+
completion: {
|
|
1172
|
+
scorers: [testsScorer],
|
|
1173
|
+
strategy: 'all', // all scorers must pass (score >= 0.5)
|
|
1174
|
+
},
|
|
1175
|
+
maxSteps: 3,
|
|
1176
|
+
});
|
|
1177
|
+
```
|
|
481
1178
|
|
|
482
|
-
|
|
1179
|
+
**What this enables:**
|
|
1180
|
+
- **Programmatic completion checks**: Define objective criteria for task completion instead of relying on the default LLM-based check
|
|
1181
|
+
- **Automatic retry with feedback**: When a scorer returns `score: 0`, its reason is injected into the conversation so the network can address the gap on the next iteration
|
|
1182
|
+
- **Composable validation**: Combine multiple scorers with `strategy: 'all'` (all must pass) or `strategy: 'any'` (at least one must pass)
|
|
483
1183
|
|
|
484
|
-
|
|
485
|
-
import { Mastra } from '@mastra/core';
|
|
486
|
-
import { AzureOpenAIGateway } from '@mastra/core/llm';
|
|
1184
|
+
This replaces guesswork with reliable, repeatable validation that ensures agent networks produce outputs meeting your specific requirements.
|
|
487
1185
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
1186
|
+
- Add MCP tool annotations and metadata support to `ToolAction` and `Tool` ([#11841](https://github.com/mastra-ai/mastra/pull/11841))
|
|
1187
|
+
|
|
1188
|
+
Tools can now surface UI hints like `title`, `readOnlyHint`, `destructiveHint`, `idempotentHint`, and `openWorldHint` via the `mcp.annotations` field, and pass arbitrary metadata to MCP clients via `mcp._meta`. These MCP-specific properties are grouped under the `mcp` property to clearly indicate they only apply when tools are exposed via MCP.
|
|
1189
|
+
|
|
1190
|
+
```typescript
|
|
1191
|
+
import { createTool } from '@mastra/core/tools';
|
|
1192
|
+
|
|
1193
|
+
const myTool = createTool({
|
|
1194
|
+
id: 'weather',
|
|
1195
|
+
description: 'Get weather for a location',
|
|
1196
|
+
mcp: {
|
|
1197
|
+
annotations: {
|
|
1198
|
+
title: 'Weather Lookup',
|
|
1199
|
+
readOnlyHint: true,
|
|
1200
|
+
destructiveHint: false,
|
|
1201
|
+
},
|
|
1202
|
+
_meta: { version: '1.0.0' },
|
|
1203
|
+
},
|
|
1204
|
+
execute: async ({ location }) => fetchWeather(location),
|
|
497
1205
|
});
|
|
1206
|
+
```
|
|
1207
|
+
|
|
1208
|
+
- Add `disableInit` option to all storage adapters ([#10851](https://github.com/mastra-ai/mastra/pull/10851))
|
|
1209
|
+
|
|
1210
|
+
Adds a new `disableInit` config option to all storage providers that allows users to disable automatic table creation/migrations at runtime. This is useful for CI/CD pipelines where you want to run migrations during deployment with elevated credentials, then run the application with `disableInit: true` so it doesn't attempt schema changes at runtime.
|
|
1211
|
+
|
|
1212
|
+
```typescript
|
|
1213
|
+
// CI/CD script - run migrations
|
|
1214
|
+
const storage = new PostgresStore({
|
|
1215
|
+
connectionString: DATABASE_URL,
|
|
1216
|
+
id: 'pg-storage',
|
|
1217
|
+
});
|
|
1218
|
+
await storage.init();
|
|
1219
|
+
|
|
1220
|
+
// Runtime - skip auto-init
|
|
1221
|
+
const storage = new PostgresStore({
|
|
1222
|
+
connectionString: DATABASE_URL,
|
|
1223
|
+
id: 'pg-storage',
|
|
1224
|
+
disableInit: true,
|
|
1225
|
+
});
|
|
1226
|
+
```
|
|
1227
|
+
|
|
1228
|
+
- Add structured output support to agent.network() method. Users can now pass a `structuredOutput` option with a Zod schema to get typed results from network execution. ([#11701](https://github.com/mastra-ai/mastra/pull/11701))
|
|
1229
|
+
|
|
1230
|
+
The stream exposes `.object` (Promise) and `.objectStream` (ReadableStream) getters, and emits `network-object` and `network-object-result` chunk types. The structured output is generated after task completion using the provided schema.
|
|
1231
|
+
|
|
1232
|
+
```typescript
|
|
1233
|
+
const stream = await agent.network('Research AI trends', {
|
|
1234
|
+
structuredOutput: {
|
|
1235
|
+
schema: z.object({
|
|
1236
|
+
summary: z.string(),
|
|
1237
|
+
recommendations: z.array(z.string()),
|
|
1238
|
+
}),
|
|
1239
|
+
},
|
|
1240
|
+
});
|
|
1241
|
+
|
|
1242
|
+
const result = await stream.object;
|
|
1243
|
+
// result is typed: { summary: string; recommendations: string[] }
|
|
1244
|
+
```
|
|
1245
|
+
|
|
1246
|
+
- Unified `getWorkflowRunById` and `getWorkflowRunExecutionResult` into a single API that returns `WorkflowState` with both metadata and execution state. ([#11429](https://github.com/mastra-ai/mastra/pull/11429))
|
|
1247
|
+
|
|
1248
|
+
**What changed:**
|
|
1249
|
+
- `getWorkflowRunById` now returns a unified `WorkflowState` object containing metadata (runId, workflowName, resourceId, createdAt, updatedAt) along with processed execution state (status, result, error, payload, steps)
|
|
1250
|
+
- Added optional `fields` parameter to request only specific fields for better performance
|
|
1251
|
+
- Added optional `withNestedWorkflows` parameter to control nested workflow step inclusion
|
|
1252
|
+
- Removed `getWorkflowRunExecutionResult` - use `getWorkflowRunById` instead (breaking change)
|
|
1253
|
+
- Removed `/execution-result` API endpoints from server (breaking change)
|
|
1254
|
+
- Removed `runExecutionResult()` method from client SDK (breaking change)
|
|
1255
|
+
- Removed `GetWorkflowRunExecutionResultResponse` type from client SDK (breaking change)
|
|
1256
|
+
|
|
1257
|
+
**Before:**
|
|
1258
|
+
|
|
1259
|
+
```typescript
|
|
1260
|
+
// Had to call two different methods for different data
|
|
1261
|
+
const run = await workflow.getWorkflowRunById(runId); // Returns raw WorkflowRun with snapshot
|
|
1262
|
+
const result = await workflow.getWorkflowRunExecutionResult(runId); // Returns processed execution state
|
|
1263
|
+
```
|
|
1264
|
+
|
|
1265
|
+
**After:**
|
|
1266
|
+
|
|
1267
|
+
```typescript
|
|
1268
|
+
// Single method returns everything
|
|
1269
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
1270
|
+
// Returns: { runId, workflowName, resourceId, createdAt, updatedAt, status, result, error, payload, steps }
|
|
1271
|
+
|
|
1272
|
+
// Request only specific fields for better performance (avoids expensive step fetching)
|
|
1273
|
+
const status = await workflow.getWorkflowRunById(runId, { fields: ['status'] });
|
|
1274
|
+
|
|
1275
|
+
// Skip nested workflow steps for faster response
|
|
1276
|
+
const run = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });
|
|
1277
|
+
```
|
|
1278
|
+
|
|
1279
|
+
**Why:** The previous API required calling two separate methods to get complete workflow run information. This unification simplifies the API surface and gives users control over performance - fetching all steps (especially nested workflows) can be expensive, so the `fields` and `withNestedWorkflows` options let users request only what they need.
|
|
1280
|
+
|
|
1281
|
+
- Rename LLM span types and attributes to use Model prefix ([#9105](https://github.com/mastra-ai/mastra/pull/9105))
|
|
1282
|
+
|
|
1283
|
+
BREAKING CHANGE: This release renames tracing span types and attribute interfaces to use the "Model" prefix instead of "LLM":
|
|
1284
|
+
- `AISpanType.LLM_GENERATION` → `AISpanType.MODEL_GENERATION`
|
|
1285
|
+
- `AISpanType.LLM_STEP` → `AISpanType.MODEL_STEP`
|
|
1286
|
+
- `AISpanType.LLM_CHUNK` → `AISpanType.MODEL_CHUNK`
|
|
1287
|
+
- `LLMGenerationAttributes` → `ModelGenerationAttributes`
|
|
1288
|
+
- `LLMStepAttributes` → `ModelStepAttributes`
|
|
1289
|
+
- `LLMChunkAttributes` → `ModelChunkAttributes`
|
|
1290
|
+
- `InternalSpans.LLM` → `InternalSpans.MODEL`
|
|
1291
|
+
|
|
1292
|
+
This change better reflects that these span types apply to all AI models, not just Large Language Models.
|
|
1293
|
+
|
|
1294
|
+
Migration guide:
|
|
1295
|
+
- Update all imports: `import { ModelGenerationAttributes } from '@mastra/core/ai-tracing'`
|
|
1296
|
+
- Update span type references: `AISpanType.MODEL_GENERATION`
|
|
1297
|
+
- Update InternalSpans usage: `InternalSpans.MODEL`
|
|
1298
|
+
|
|
1299
|
+
### Patch Changes
|
|
1300
|
+
|
|
1301
|
+
- dependencies updates: ([#10110](https://github.com/mastra-ai/mastra/pull/10110))
|
|
1302
|
+
- Updated dependency [`hono-openapi@^1.1.1` ↗︎](https://www.npmjs.com/package/hono-openapi/v/1.1.1) (from `^0.4.8`, in `dependencies`)
|
|
1303
|
+
|
|
1304
|
+
- dependencies updates: ([#10131](https://github.com/mastra-ai/mastra/pull/10131))
|
|
1305
|
+
- Updated dependency [`hono@^4.10.5` ↗︎](https://www.npmjs.com/package/hono/v/4.10.5) (from `^4.9.7`, in `dependencies`)
|
|
1306
|
+
|
|
1307
|
+
- dependencies updates: ([#10133](https://github.com/mastra-ai/mastra/pull/10133))
|
|
1308
|
+
- Updated dependency [`js-tiktoken@^1.0.21` ↗︎](https://www.npmjs.com/package/js-tiktoken/v/1.0.21) (from `^1.0.20`, in `dependencies`)
|
|
1309
|
+
|
|
1310
|
+
- dependencies updates: ([#10191](https://github.com/mastra-ai/mastra/pull/10191))
|
|
1311
|
+
- Updated dependency [`dotenv@^17.2.3` ↗︎](https://www.npmjs.com/package/dotenv/v/17.2.3) (from `^16.6.1`, in `dependencies`)
|
|
1312
|
+
|
|
1313
|
+
- Add agentId and agentName attributes to MODEL_GENERATION spans. This allows users to correlate gen_ai.usage metrics with specific agents when analyzing LLM operation spans. The attributes are exported as gen_ai.agent.id and gen_ai.agent.name in the OtelExporter. ([#10984](https://github.com/mastra-ai/mastra/pull/10984))
|
|
1314
|
+
|
|
1315
|
+
- Added `customSpanFormatter` option to exporters for per-exporter span transformation. This allows different formatting per exporter and supports both synchronous and asynchronous operations, including async data enrichment. ([#11985](https://github.com/mastra-ai/mastra/pull/11985))
|
|
1316
|
+
|
|
1317
|
+
**Configuration example:**
|
|
1318
|
+
|
|
1319
|
+
```ts
|
|
1320
|
+
import { DefaultExporter } from '@mastra/observability';
|
|
1321
|
+
import { SpanType } from '@mastra/core/observability';
|
|
1322
|
+
import type { CustomSpanFormatter } from '@mastra/core/observability';
|
|
1323
|
+
|
|
1324
|
+
// Sync formatter
|
|
1325
|
+
const plainTextFormatter: CustomSpanFormatter = span => {
|
|
1326
|
+
if (span.type === SpanType.AGENT_RUN && Array.isArray(span.input)) {
|
|
1327
|
+
const userMessage = span.input.find(m => m.role === 'user');
|
|
1328
|
+
return { ...span, input: userMessage?.content ?? span.input };
|
|
1329
|
+
}
|
|
1330
|
+
return span;
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1333
|
+
// Async formatter for data enrichment
|
|
1334
|
+
const enrichmentFormatter: CustomSpanFormatter = async span => {
|
|
1335
|
+
const userData = await fetchUserData(span.metadata?.userId);
|
|
1336
|
+
return { ...span, metadata: { ...span.metadata, userName: userData.name } };
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
const exporter = new DefaultExporter({
|
|
1340
|
+
customSpanFormatter: plainTextFormatter,
|
|
1341
|
+
});
|
|
1342
|
+
```
|
|
1343
|
+
|
|
1344
|
+
Also added `chainFormatters` utility to combine multiple formatters (supports mixed sync/async):
|
|
1345
|
+
|
|
1346
|
+
```ts
|
|
1347
|
+
import { chainFormatters } from '@mastra/observability';
|
|
1348
|
+
|
|
1349
|
+
const exporter = new BraintrustExporter({
|
|
1350
|
+
customSpanFormatter: chainFormatters([syncFormatter, asyncFormatter]),
|
|
1351
|
+
});
|
|
1352
|
+
```
|
|
1353
|
+
|
|
1354
|
+
- Add embedded documentation support for Mastra packages ([#11472](https://github.com/mastra-ai/mastra/pull/11472))
|
|
1355
|
+
|
|
1356
|
+
Mastra packages now include embedded documentation in the published npm package under `dist/docs/`. This enables coding agents and AI assistants to understand and use the framework by reading documentation directly from `node_modules`.
|
|
1357
|
+
|
|
1358
|
+
Each package includes:
|
|
1359
|
+
- **SKILL.md** - Entry point explaining the package's purpose and capabilities
|
|
1360
|
+
- **SOURCE_MAP.json** - Machine-readable index mapping exports to types and implementation files
|
|
1361
|
+
- **Topic folders** - Conceptual documentation organized by feature area
|
|
1362
|
+
|
|
1363
|
+
Documentation is driven by the `packages` frontmatter field in MDX files, which maps docs to their corresponding packages. CI validation ensures all docs include this field.
|
|
1364
|
+
|
|
1365
|
+
- Add exponential backoff to model retry logic to prevent cascading failures ([#9798](https://github.com/mastra-ai/mastra/pull/9798))
|
|
1366
|
+
|
|
1367
|
+
When AI model calls fail, the system now implements exponential backoff (1s, 2s, 4s, 8s, max 10s) before retrying instead of immediately hammering the API. This prevents:
|
|
1368
|
+
- Rate limit violations from getting worse
|
|
1369
|
+
- Cascading failures across all fallback models
|
|
1370
|
+
- Wasted API quota by burning through retries instantly
|
|
1371
|
+
- Production outages when all models fail due to rate limits
|
|
1372
|
+
|
|
1373
|
+
The backoff gives APIs time to recover from transient failures and rate limiting.
|
|
1374
|
+
|
|
1375
|
+
- Add support for `retries` and `scorers` parameters across all `createStep` overloads.
|
|
1376
|
+
([#11495](https://github.com/mastra-ai/mastra/pull/11495))
|
|
1377
|
+
|
|
1378
|
+
The `createStep` function now includes support for the `retries` and `scorers` fields across all step creation patterns, enabling step-level retry configuration and AI evaluation support for regular steps, agent-based steps, and tool-based steps.
|
|
1379
|
+
|
|
1380
|
+
```typescript
|
|
1381
|
+
import { init } from '@mastra/inngest';
|
|
1382
|
+
import { z } from 'zod';
|
|
1383
|
+
|
|
1384
|
+
const { createStep } = init(inngest);
|
|
1385
|
+
|
|
1386
|
+
// 1. Regular step with retries
|
|
1387
|
+
const regularStep = createStep({
|
|
1388
|
+
id: 'api-call',
|
|
1389
|
+
inputSchema: z.object({ url: z.string() }),
|
|
1390
|
+
outputSchema: z.object({ data: z.any() }),
|
|
1391
|
+
retries: 3, // ← Will retry up to 3 times on failure
|
|
1392
|
+
execute: async ({ inputData }) => {
|
|
1393
|
+
const response = await fetch(inputData.url);
|
|
1394
|
+
return { data: await response.json() };
|
|
1395
|
+
},
|
|
1396
|
+
});
|
|
1397
|
+
|
|
1398
|
+
// 2. Agent step with retries and scorers
|
|
1399
|
+
const agentStep = createStep(myAgent, {
|
|
1400
|
+
retries: 3,
|
|
1401
|
+
scorers: [{ id: 'accuracy-scorer', scorer: myAccuracyScorer }],
|
|
1402
|
+
});
|
|
1403
|
+
|
|
1404
|
+
// 3. Tool step with retries and scorers
|
|
1405
|
+
const toolStep = createStep(myTool, {
|
|
1406
|
+
retries: 2,
|
|
1407
|
+
scorers: [{ id: 'quality-scorer', scorer: myQualityScorer }],
|
|
1408
|
+
});
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
This change ensures API consistency across all `createStep` overloads. All step types now support retry and evaluation configurations.
|
|
1412
|
+
|
|
1413
|
+
This is a non-breaking change - steps without these parameters continue to work exactly as before.
|
|
1414
|
+
|
|
1415
|
+
Fixes #9351
|
|
1416
|
+
|
|
1417
|
+
- Add time-to-first-token (TTFT) support for Langfuse integration ([#10781](https://github.com/mastra-ai/mastra/pull/10781))
|
|
1418
|
+
|
|
1419
|
+
Adds `completionStartTime` to model generation spans, which Langfuse uses to calculate TTFT metrics. The timestamp is automatically captured when the first content chunk arrives during streaming.
|
|
1420
|
+
|
|
1421
|
+
```typescript
|
|
1422
|
+
// completionStartTime is now automatically captured and sent to Langfuse
|
|
1423
|
+
// enabling TTFT metrics in your Langfuse dashboard
|
|
1424
|
+
const result = await agent.stream('Hello');
|
|
1425
|
+
```
|
|
1426
|
+
|
|
1427
|
+
- When using agent networks, the routing agent could fail with a cryptic `TypeError: Cannot read properties of undefined` if the generation response was missing or malformed. This made it difficult to diagnose why routing failed. The release now throws a descriptive error with debugging details (response text, finish reason, usage) to help identify the root cause. ([#12028](https://github.com/mastra-ai/mastra/pull/12028))
|
|
1428
|
+
|
|
1429
|
+
Fixes #11749
|
|
1430
|
+
|
|
1431
|
+
- Remove `streamVNext`, `resumeStreamVNext`, and `observeStreamVNext` methods, call `stream`, `resumeStream` and `observeStream` directly ([#11499](https://github.com/mastra-ai/mastra/pull/11499))
|
|
1432
|
+
|
|
1433
|
+
```diff
|
|
1434
|
+
+ const run = await workflow.createRun({ runId: '123' });
|
|
1435
|
+
- const stream = await run.streamVNext({ inputData: { ... } });
|
|
1436
|
+
+ const stream = await run.stream({ inputData: { ... } });
|
|
1437
|
+
```
|
|
1438
|
+
|
|
1439
|
+
- Update provider registry and model documentation with latest models and providers ([`f743dbb`](https://github.com/mastra-ai/mastra/commit/f743dbb8b40d1627b5c10c0e6fc154f4ebb6e394))
|
|
1440
|
+
|
|
1441
|
+
- Add Azure OpenAI gateway ([#9990](https://github.com/mastra-ai/mastra/pull/9990))
|
|
1442
|
+
|
|
1443
|
+
The Azure OpenAI gateway supports three configuration modes:
|
|
1444
|
+
1. **Static deployments**: Provide deployment names from Azure Portal
|
|
1445
|
+
2. **Dynamic discovery**: Query Azure Management API for available deployments
|
|
1446
|
+
3. **Manual**: Specify deployment names when creating agents
|
|
1447
|
+
|
|
1448
|
+
**Usage**
|
|
1449
|
+
|
|
1450
|
+
```typescript
|
|
1451
|
+
import { Mastra } from '@mastra/core';
|
|
1452
|
+
import { AzureOpenAIGateway } from '@mastra/core/llm';
|
|
1453
|
+
|
|
1454
|
+
// Static mode (recommended)
|
|
1455
|
+
export const mastra = new Mastra({
|
|
1456
|
+
gateways: [
|
|
1457
|
+
new AzureOpenAIGateway({
|
|
1458
|
+
resourceName: process.env.AZURE_RESOURCE_NAME!,
|
|
1459
|
+
apiKey: process.env.AZURE_API_KEY!,
|
|
1460
|
+
deployments: ['gpt-4-prod', 'gpt-35-turbo-dev'],
|
|
1461
|
+
}),
|
|
1462
|
+
],
|
|
1463
|
+
});
|
|
1464
|
+
|
|
1465
|
+
// Dynamic discovery mode
|
|
1466
|
+
export const mastra = new Mastra({
|
|
1467
|
+
gateways: [
|
|
1468
|
+
new AzureOpenAIGateway({
|
|
1469
|
+
resourceName: process.env.AZURE_RESOURCE_NAME!,
|
|
1470
|
+
apiKey: process.env.AZURE_API_KEY!,
|
|
1471
|
+
management: {
|
|
1472
|
+
tenantId: process.env.AZURE_TENANT_ID!,
|
|
1473
|
+
clientId: process.env.AZURE_CLIENT_ID!,
|
|
1474
|
+
clientSecret: process.env.AZURE_CLIENT_SECRET!,
|
|
1475
|
+
subscriptionId: process.env.AZURE_SUBSCRIPTION_ID!,
|
|
1476
|
+
resourceGroup: 'my-resource-group',
|
|
1477
|
+
},
|
|
1478
|
+
}),
|
|
1479
|
+
],
|
|
1480
|
+
});
|
|
1481
|
+
|
|
1482
|
+
// Use Azure OpenAI models
|
|
1483
|
+
const agent = new Agent({
|
|
1484
|
+
model: 'azure-openai/gpt-4-deployment',
|
|
1485
|
+
instructions: 'You are a helpful assistant',
|
|
1486
|
+
});
|
|
1487
|
+
```
|
|
1488
|
+
|
|
1489
|
+
- Fix Anthropic API error when tool calls have empty input objects ([#11474](https://github.com/mastra-ai/mastra/pull/11474))
|
|
1490
|
+
|
|
1491
|
+
Fixes issue #11376 where Anthropic models would fail with error "messages.17.content.2.tool_use.input: Field required" when a tool call in a previous step had an empty object `{}` as input.
|
|
1492
|
+
|
|
1493
|
+
The fix adds proper reconstruction of tool call arguments when converting messages to AIV5 model format. Tool-result parts now correctly include the `input` field from the matching tool call, which is required by Anthropic's API validation.
|
|
1494
|
+
|
|
1495
|
+
Changes:
|
|
1496
|
+
- Added `findToolCallArgs()` helper method to search through messages and retrieve original tool call arguments
|
|
1497
|
+
- Enhanced `aiV5UIMessagesToAIV5ModelMessages()` to populate the `input` field on tool-result parts
|
|
1498
|
+
- Added comprehensive test coverage for empty object inputs, parameterized inputs, and multi-turn conversations
|
|
1499
|
+
|
|
1500
|
+
- Add additional context to workflow `onFinish` and `onError` callbacks ([#11705](https://github.com/mastra-ai/mastra/pull/11705))
|
|
1501
|
+
|
|
1502
|
+
The `onFinish` and `onError` lifecycle callbacks now receive additional properties:
|
|
1503
|
+
- `runId` - The unique identifier for the workflow run
|
|
1504
|
+
- `workflowId` - The workflow's identifier
|
|
1505
|
+
- `resourceId` - Optional resource identifier (if provided when creating the run)
|
|
1506
|
+
- `getInitData()` - Function that returns the initial input data passed to the workflow
|
|
1507
|
+
- `mastra` - The Mastra instance (if workflow is registered with Mastra)
|
|
1508
|
+
- `requestContext` - Request-scoped context data
|
|
1509
|
+
- `logger` - The workflow's logger instance
|
|
1510
|
+
- `state` - The workflow's current state object
|
|
1511
|
+
|
|
1512
|
+
```typescript
|
|
1513
|
+
const workflow = createWorkflow({
|
|
1514
|
+
id: 'order-processing',
|
|
1515
|
+
inputSchema: z.object({ orderId: z.string() }),
|
|
1516
|
+
outputSchema: z.object({ status: z.string() }),
|
|
1517
|
+
options: {
|
|
1518
|
+
onFinish: async ({ runId, workflowId, getInitData, logger, state, mastra }) => {
|
|
1519
|
+
const inputData = getInitData();
|
|
1520
|
+
logger.info(`Workflow ${workflowId} run ${runId} completed`, {
|
|
1521
|
+
orderId: inputData.orderId,
|
|
1522
|
+
finalState: state,
|
|
1523
|
+
});
|
|
1524
|
+
|
|
1525
|
+
// Access other Mastra components if needed
|
|
1526
|
+
const agent = mastra?.getAgent('notification-agent');
|
|
1527
|
+
},
|
|
1528
|
+
onError: async ({ runId, workflowId, error, logger, requestContext }) => {
|
|
1529
|
+
logger.error(`Workflow ${workflowId} run ${runId} failed: ${error?.message}`);
|
|
1530
|
+
// Access request context for additional debugging
|
|
1531
|
+
const userId = requestContext.get('userId');
|
|
1532
|
+
},
|
|
1533
|
+
},
|
|
1534
|
+
});
|
|
1535
|
+
```
|
|
1536
|
+
|
|
1537
|
+
- Fix workflow tool not executing when requireApproval is true and tool call is approved ([#11538](https://github.com/mastra-ai/mastra/pull/11538))
|
|
1538
|
+
|
|
1539
|
+
- unexpected json parse issue, log error but dont fail ([#10241](https://github.com/mastra-ai/mastra/pull/10241))
|
|
1540
|
+
|
|
1541
|
+
- Updated OtelExporters, Bridge, and Arize packages to better implement GenAI v1.38.0 Otel Semantic Conventions. See: ([#10591](https://github.com/mastra-ai/mastra/pull/10591))
|
|
1542
|
+
https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/gen-ai/README.md
|
|
1543
|
+
|
|
1544
|
+
- Standardize error IDs across all storage and vector stores using centralized helper functions (`createStorageErrorId` and `createVectorErrorId`). This ensures consistent error ID patterns (`MASTRA_STORAGE_{STORE}_{OPERATION}_{STATUS}` and `MASTRA_VECTOR_{STORE}_{OPERATION}_{STATUS}`) across the codebase for better error tracking and debugging. ([#10913](https://github.com/mastra-ai/mastra/pull/10913))
|
|
1545
|
+
|
|
1546
|
+
- Remove redundant toolCalls from network agent finalResult ([#11189](https://github.com/mastra-ai/mastra/pull/11189))
|
|
1547
|
+
|
|
1548
|
+
The network agent's `finalResult` was storing `toolCalls` separately even though all tool call information is already present in the `messages` array (as `tool-call` and `tool-result` type messages). This caused significant token waste since the routing agent reads this data from memory on every iteration.
|
|
1549
|
+
|
|
1550
|
+
**Before:** `finalResult: { text, toolCalls, messages }`
|
|
1551
|
+
**After:** `finalResult: { text, messages }`
|
|
1552
|
+
|
|
1553
|
+
+**Migration:** If you were accessing `finalResult.toolCalls`, retrieve tool calls from `finalResult.messages` by filtering for messages with `type: 'tool-call'`.
|
|
1554
|
+
|
|
1555
|
+
Updated `@mastra/react` to extract tool calls directly from the `messages` array instead of the removed `toolCalls` field when resolving initial messages from memory.
|
|
1556
|
+
|
|
1557
|
+
Fixes #11059
|
|
1558
|
+
|
|
1559
|
+
- Fixed a bug in agent networks where sometimes the task name was empty ([#10629](https://github.com/mastra-ai/mastra/pull/10629))
|
|
1560
|
+
|
|
1561
|
+
- Fix agent onChunk callback receiving wrapped chunk instead of direct chunk ([#9350](https://github.com/mastra-ai/mastra/pull/9350))
|
|
1562
|
+
|
|
1563
|
+
- When calling `abort()` inside a `processInputStep` processor, the TripWire was being caught by the model retry logic instead of emitting a tripwire chunk to the stream. ([#11343](https://github.com/mastra-ai/mastra/pull/11343))
|
|
1564
|
+
|
|
1565
|
+
Before this fix, processors using `processInputStep` with abort would see errors like:
|
|
1566
|
+
|
|
1567
|
+
```
|
|
1568
|
+
Error executing model gpt-4o-mini, attempt 1==== TripWire [Error]: Potentially harmful content detected
|
|
1569
|
+
```
|
|
1570
|
+
|
|
1571
|
+
Now the TripWire is properly handled - it emits a tripwire chunk and signals the abort correctly,
|
|
1572
|
+
|
|
1573
|
+
- Embed AI types to fix peerdeps mismatches ([`9650cce`](https://github.com/mastra-ai/mastra/commit/9650cce52a1d917ff9114653398e2a0f5c3ba808))
|
|
1574
|
+
|
|
1575
|
+
- Deprecate `runCount` parameter in favor of `retryCount` for better naming clarity. The name `runCount` was misleading as it doesn't represent the total number of times a step has run, but rather the number of retry attempts made for a step. ([#9153](https://github.com/mastra-ai/mastra/pull/9153))
|
|
1576
|
+
|
|
1577
|
+
`runCount` is available in `execute()` functions and methods that interact with the step execution. This also applies to condition functions and loop condition functions that use this parameter. If your code uses `runCount`, change the name to `retryCount`.
|
|
1578
|
+
|
|
1579
|
+
Here's an example migration:
|
|
1580
|
+
|
|
1581
|
+
```diff
|
|
1582
|
+
const myStep = createStep({
|
|
1583
|
+
// Rest of step...
|
|
1584
|
+
- execute: async ({ runCount, ...params }) => {
|
|
1585
|
+
+ execute: async ({ retryCount, ...params }) => {
|
|
1586
|
+
// ... rest of your logic
|
|
1587
|
+
}
|
|
1588
|
+
});
|
|
1589
|
+
```
|
|
1590
|
+
|
|
1591
|
+
- Set correct peer dependency range for `@mastra/observability` ([#9908](https://github.com/mastra-ai/mastra/pull/9908))
|
|
1592
|
+
|
|
1593
|
+
- Add requestContext column if it does not exist ([#9786](https://github.com/mastra-ai/mastra/pull/9786))
|
|
1594
|
+
|
|
1595
|
+
- Only handle download image asset transformation if needed ([#10122](https://github.com/mastra-ai/mastra/pull/10122))
|
|
1596
|
+
|
|
1597
|
+
- Fix model-level and runtime header support for LLM calls ([#11275](https://github.com/mastra-ai/mastra/pull/11275))
|
|
1598
|
+
|
|
1599
|
+
This fixes a bug where custom headers configured on models (like `anthropic-beta`) were not being passed through to the underlying AI SDK calls. The fix properly handles headers from multiple sources with correct priority:
|
|
1600
|
+
|
|
1601
|
+
**Header Priority (low to high):**
|
|
1602
|
+
1. Model config headers - Headers set in model configuration
|
|
1603
|
+
2. ModelSettings headers - Runtime headers that override model config
|
|
1604
|
+
3. Provider-level headers - Headers baked into AI SDK providers (not overridden)
|
|
1605
|
+
|
|
1606
|
+
**Examples that now work:**
|
|
1607
|
+
|
|
1608
|
+
```typescript
|
|
1609
|
+
// Model config headers
|
|
1610
|
+
new Agent({
|
|
1611
|
+
model: {
|
|
1612
|
+
id: 'anthropic/claude-4-5-sonnet',
|
|
1613
|
+
headers: { 'anthropic-beta': 'context-1m-2025-08-07' },
|
|
1614
|
+
},
|
|
1615
|
+
});
|
|
1616
|
+
|
|
1617
|
+
// Runtime headers override config
|
|
1618
|
+
agent.generate('...', {
|
|
1619
|
+
modelSettings: { headers: { 'x-custom': 'runtime-value' } },
|
|
1620
|
+
});
|
|
1621
|
+
|
|
1622
|
+
// Provider-level headers preserved
|
|
1623
|
+
const openai = createOpenAI({ headers: { 'openai-organization': 'org-123' } });
|
|
1624
|
+
new Agent({ model: openai('gpt-4o-mini') });
|
|
1625
|
+
```
|
|
1626
|
+
|
|
1627
|
+
- - Fix tool suspension throwing error when `outputSchema` is passed to tool during creation ([#10444](https://github.com/mastra-ai/mastra/pull/10444))
|
|
1628
|
+
- Pass `suspendSchema` and `resumeSchema` from tool into step created when creating step from tool
|
|
1629
|
+
|
|
1630
|
+
- Consolidate memory integration tests and fix working memory filtering in MessageHistory processor ([#11367](https://github.com/mastra-ai/mastra/pull/11367))
|
|
1631
|
+
|
|
1632
|
+
Moved `extractWorkingMemoryTags`, `removeWorkingMemoryTags`, and `extractWorkingMemoryContent` utilities from `@mastra/memory` to `@mastra/core/memory` so they can be used by the `MessageHistory` processor.
|
|
1633
|
+
|
|
1634
|
+
Updated `MessageHistory.filterMessagesForPersistence()` to properly filter out `updateWorkingMemory` tool invocations and strip working memory tags from text content, fixing an issue where working memory tool call arguments were polluting saved message history for v5+ models.
|
|
1635
|
+
|
|
1636
|
+
Also consolidated integration tests for agent-memory, working-memory, and pg-storage into shared test functions that can run against multiple model versions (v4, v5, v6).
|
|
1637
|
+
|
|
1638
|
+
- Fix type safety for message ordering - restrict `orderBy` to only accept `'createdAt'` field ([#11069](https://github.com/mastra-ai/mastra/pull/11069))
|
|
1639
|
+
|
|
1640
|
+
Messages don't have an `updatedAt` field, but the previous type allowed ordering by it, which would return empty results. This change adds compile-time type safety by making `StorageOrderBy` generic and restricting `StorageListMessagesInput.orderBy` to only accept `'createdAt'`. The API validation schemas have also been updated to reject invalid orderBy values at runtime.
|
|
1641
|
+
|
|
1642
|
+
- Fixed agent network mode failing with "Cannot read properties of undefined" error when tools or workflows don't have an `inputSchema` defined. ([#12063](https://github.com/mastra-ai/mastra/pull/12063))
|
|
1643
|
+
- **@mastra/core:** Fixed `getRoutingAgent()` to handle tools and workflows without `inputSchema` by providing a default empty schema fallback.
|
|
1644
|
+
- **@mastra/schema-compat:** Fixed Zod v4 optional/nullable fields producing invalid JSON schema for OpenAI structured outputs. OpenAI now correctly receives `type: ["string", "null"]` instead of `anyOf` patterns that were rejected with "must have a 'type' key" error.
|
|
1645
|
+
|
|
1646
|
+
- Fix invalid state: Controller is already closed ([`932d63d`](https://github.com/mastra-ai/mastra/commit/932d63dd51be9c8bf1e00e3671fe65606c6fb9cd))
|
|
1647
|
+
|
|
1648
|
+
Fixes #11005
|
|
1649
|
+
|
|
1650
|
+
- Add support for AI SDK's `needsApproval` in tools. ([#11388](https://github.com/mastra-ai/mastra/pull/11388))
|
|
1651
|
+
|
|
1652
|
+
**AI SDK tools with static approval:**
|
|
1653
|
+
|
|
1654
|
+
```typescript
|
|
1655
|
+
import { tool } from 'ai';
|
|
1656
|
+
import { z } from 'zod';
|
|
1657
|
+
|
|
1658
|
+
const weatherTool = tool({
|
|
1659
|
+
description: 'Get weather information',
|
|
1660
|
+
inputSchema: z.object({ city: z.string() }),
|
|
1661
|
+
needsApproval: true,
|
|
1662
|
+
execute: async ({ city }) => {
|
|
1663
|
+
return { weather: 'sunny', temp: 72 };
|
|
1664
|
+
},
|
|
1665
|
+
});
|
|
1666
|
+
```
|
|
1667
|
+
|
|
1668
|
+
**AI SDK tools with dynamic approval:**
|
|
1669
|
+
|
|
1670
|
+
```typescript
|
|
1671
|
+
const paymentTool = tool({
|
|
1672
|
+
description: 'Process payment',
|
|
1673
|
+
inputSchema: z.object({ amount: z.number() }),
|
|
1674
|
+
needsApproval: async ({ amount }) => amount > 1000,
|
|
1675
|
+
execute: async ({ amount }) => {
|
|
1676
|
+
return { success: true, amount };
|
|
1677
|
+
},
|
|
1678
|
+
});
|
|
1679
|
+
```
|
|
1680
|
+
|
|
1681
|
+
**Mastra tools continue to work with `requireApproval`:**
|
|
1682
|
+
|
|
1683
|
+
```typescript
|
|
1684
|
+
import { createTool } from '@mastra/core';
|
|
1685
|
+
|
|
1686
|
+
const deleteTool = createTool({
|
|
1687
|
+
id: 'delete-file',
|
|
1688
|
+
description: 'Delete a file',
|
|
1689
|
+
requireApproval: true,
|
|
1690
|
+
inputSchema: z.object({ path: z.string() }),
|
|
1691
|
+
execute: async ({ path }) => {
|
|
1692
|
+
return { deleted: true };
|
|
1693
|
+
},
|
|
1694
|
+
});
|
|
1695
|
+
```
|
|
1696
|
+
|
|
1697
|
+
- Add serializedStepGraph to runExecutionResult response ([#10004](https://github.com/mastra-ai/mastra/pull/10004))
|
|
1698
|
+
|
|
1699
|
+
- Add `onFinish` and `onError` lifecycle callbacks to workflow options ([#11200](https://github.com/mastra-ai/mastra/pull/11200))
|
|
1700
|
+
|
|
1701
|
+
Workflows now support lifecycle callbacks for server-side handling of workflow completion and errors:
|
|
1702
|
+
- `onFinish`: Called when workflow completes with any status (success, failed, suspended, tripwire)
|
|
1703
|
+
- `onError`: Called only when workflow fails (failed or tripwire status)
|
|
1704
|
+
|
|
1705
|
+
```typescript
|
|
1706
|
+
const workflow = createWorkflow({
|
|
1707
|
+
id: 'my-workflow',
|
|
1708
|
+
inputSchema: z.object({ ... }),
|
|
1709
|
+
outputSchema: z.object({ ... }),
|
|
1710
|
+
options: {
|
|
1711
|
+
onFinish: async (result) => {
|
|
1712
|
+
// Handle any workflow completion
|
|
1713
|
+
await updateJobStatus(result.status);
|
|
1714
|
+
},
|
|
1715
|
+
onError: async (errorInfo) => {
|
|
1716
|
+
// Handle workflow failures
|
|
1717
|
+
await logError(errorInfo.error);
|
|
1718
|
+
},
|
|
1719
|
+
},
|
|
1720
|
+
});
|
|
1721
|
+
```
|
|
1722
|
+
|
|
1723
|
+
Both callbacks support sync and async functions. Callback errors are caught and logged, not propagated to the workflow result.
|
|
1724
|
+
|
|
1725
|
+
- Adds `tool-result` and `tool-error` chunks to the processor.processOutputStream path. Processors now have access to these two chunks. ([#10645](https://github.com/mastra-ai/mastra/pull/10645))
|
|
1726
|
+
|
|
1727
|
+
- Add `onOutput` hook for tools ([#10466](https://github.com/mastra-ai/mastra/pull/10466))
|
|
1728
|
+
|
|
1729
|
+
Tools now support an `onOutput` lifecycle hook that is invoked after successful tool execution. This complements the existing `onInputStart`, `onInputDelta`, and `onInputAvailable` hooks to provide complete visibility into the tool execution lifecycle.
|
|
1730
|
+
|
|
1731
|
+
The `onOutput` hook receives:
|
|
1732
|
+
- `output`: The tool's return value (typed according to `outputSchema`)
|
|
1733
|
+
- `toolCallId`: Unique identifier for the tool call
|
|
1734
|
+
- `toolName`: The name of the tool that was executed
|
|
1735
|
+
- `abortSignal`: Signal for detecting if the operation should be cancelled
|
|
1736
|
+
|
|
1737
|
+
Example usage:
|
|
1738
|
+
|
|
1739
|
+
```typescript
|
|
1740
|
+
import { createTool } from '@mastra/core/tools';
|
|
1741
|
+
import { z } from 'zod';
|
|
1742
|
+
|
|
1743
|
+
export const weatherTool = createTool({
|
|
1744
|
+
id: 'weather-tool',
|
|
1745
|
+
description: 'Get weather information',
|
|
1746
|
+
outputSchema: z.object({
|
|
1747
|
+
temperature: z.number(),
|
|
1748
|
+
conditions: z.string(),
|
|
1749
|
+
}),
|
|
1750
|
+
execute: async input => {
|
|
1751
|
+
return { temperature: 72, conditions: 'sunny' };
|
|
1752
|
+
},
|
|
1753
|
+
onOutput: ({ output, toolCallId, toolName }) => {
|
|
1754
|
+
console.log(`${toolName} completed:`, output);
|
|
1755
|
+
// output is fully typed based on outputSchema
|
|
1756
|
+
},
|
|
1757
|
+
});
|
|
1758
|
+
```
|
|
1759
|
+
|
|
1760
|
+
Hook execution order:
|
|
1761
|
+
1. `onInputStart` - Input streaming begins
|
|
1762
|
+
2. `onInputDelta` - Input chunks arrive (called multiple times)
|
|
1763
|
+
3. `onInputAvailable` - Complete input parsed and validated
|
|
1764
|
+
4. Tool's `execute` function runs
|
|
1765
|
+
5. `onOutput` - Tool completed successfully (NEW)
|
|
1766
|
+
|
|
1767
|
+
- Fix saveScore not persisting ID correctly, breaking getScoreById retrieval ([#10915](https://github.com/mastra-ai/mastra/pull/10915))
|
|
1768
|
+
|
|
1769
|
+
**What Changed**
|
|
1770
|
+
- saveScore now correctly returns scores that can be retrieved with getScoreById
|
|
1771
|
+
- Validation errors now include contextual information (scorer, entity, trace details) for easier debugging
|
|
1772
|
+
|
|
1773
|
+
**Impact**
|
|
1774
|
+
Previously, calling getScoreById after saveScore would return null because the generated ID wasn't persisted to the database. This is now fixed across all store implementations, ensuring consistent behavior and data integrity.
|
|
1775
|
+
|
|
1776
|
+
- Fix HITL (Human-In-The-Loop) tool execution bug when mixing tools with and without execute functions. ([#11178](https://github.com/mastra-ai/mastra/pull/11178))
|
|
1777
|
+
|
|
1778
|
+
When an agent called multiple tools simultaneously where some had `execute` functions and others didn't (HITL tools expecting `addToolResult` from the frontend), the HITL tools would incorrectly receive `result: undefined` and be marked as "output-available" instead of "input-available". This caused the agent to continue instead of pausing for user input.
|
|
1779
|
+
|
|
1780
|
+
- Track usage in workflow and agent network ([#9649](https://github.com/mastra-ai/mastra/pull/9649))
|
|
1781
|
+
|
|
1782
|
+
- Add resourceId to workflow routes ([#11166](https://github.com/mastra-ai/mastra/pull/11166))
|
|
1783
|
+
|
|
1784
|
+
- Fixed AbortSignal not propagating from parent workflows to nested sub-workflows in the evented workflow engine. ([#11142](https://github.com/mastra-ai/mastra/pull/11142))
|
|
1785
|
+
|
|
1786
|
+
Previously, canceling a parent workflow did not stop nested sub-workflows, causing them to continue running and consuming resources after the parent was canceled.
|
|
1787
|
+
|
|
1788
|
+
Now, when you cancel a parent workflow, all nested sub-workflows are automatically canceled as well, ensuring clean termination of the entire workflow tree.
|
|
1789
|
+
|
|
1790
|
+
**Example:**
|
|
1791
|
+
|
|
1792
|
+
```typescript
|
|
1793
|
+
const parentWorkflow = createWorkflow({ id: 'parent-workflow' }).then(someStep).then(nestedChildWorkflow).commit();
|
|
1794
|
+
|
|
1795
|
+
const run = await parentWorkflow.createRun();
|
|
1796
|
+
const resultPromise = run.start({ inputData: { value: 5 } });
|
|
1797
|
+
|
|
1798
|
+
// Cancel the parent workflow - nested workflows will also be canceled
|
|
1799
|
+
await run.cancel();
|
|
1800
|
+
// or use: run.abortController.abort();
|
|
1801
|
+
|
|
1802
|
+
const result = await resultPromise;
|
|
1803
|
+
// result.status === 'canceled'
|
|
1804
|
+
// All nested child workflows are also canceled
|
|
1805
|
+
```
|
|
1806
|
+
|
|
1807
|
+
Related to #11063
|
|
1808
|
+
|
|
1809
|
+
- Add new deleteVectors, updateVector by filter ([#10408](https://github.com/mastra-ai/mastra/pull/10408))
|
|
1810
|
+
|
|
1811
|
+
- Include `.input` in workflow results for both engines and remove the option to omit them from Inngest workflows. ([#10688](https://github.com/mastra-ai/mastra/pull/10688))
|
|
1812
|
+
|
|
1813
|
+
- Add support for typed structured output in agent workflow steps ([#11014](https://github.com/mastra-ai/mastra/pull/11014))
|
|
1814
|
+
|
|
1815
|
+
When wrapping an agent with `createStep()` and providing a `structuredOutput.schema`, the step's `outputSchema` is now correctly inferred from the provided schema instead of defaulting to `{ text: string }`.
|
|
1816
|
+
|
|
1817
|
+
This enables type-safe chaining of agent steps with structured output to subsequent steps:
|
|
1818
|
+
|
|
1819
|
+
```typescript
|
|
1820
|
+
const articleSchema = z.object({
|
|
1821
|
+
title: z.string(),
|
|
1822
|
+
summary: z.string(),
|
|
1823
|
+
tags: z.array(z.string()),
|
|
1824
|
+
});
|
|
1825
|
+
|
|
1826
|
+
// Agent step with structured output - outputSchema is now articleSchema
|
|
1827
|
+
const agentStep = createStep(agent, {
|
|
1828
|
+
structuredOutput: { schema: articleSchema },
|
|
1829
|
+
});
|
|
1830
|
+
|
|
1831
|
+
// Next step can receive the structured output directly
|
|
1832
|
+
const processStep = createStep({
|
|
1833
|
+
id: 'process',
|
|
1834
|
+
inputSchema: articleSchema, // Matches agent's outputSchema
|
|
1835
|
+
outputSchema: z.object({ tagCount: z.number() }),
|
|
1836
|
+
execute: async ({ inputData }) => ({
|
|
1837
|
+
tagCount: inputData.tags.length, // Fully typed!
|
|
1838
|
+
}),
|
|
1839
|
+
});
|
|
1840
|
+
|
|
1841
|
+
workflow.then(agentStep).then(processStep).commit();
|
|
1842
|
+
```
|
|
1843
|
+
|
|
1844
|
+
When `structuredOutput` is not provided, the agent step continues to use the default `{ text: string }` output schema.
|
|
1845
|
+
|
|
1846
|
+
- **Breaking Change:** `memory.readOnly` has been moved to `memory.options.readOnly` ([#11523](https://github.com/mastra-ai/mastra/pull/11523))
|
|
1847
|
+
|
|
1848
|
+
The `readOnly` option now lives inside `memory.options` alongside other memory configuration like `lastMessages` and `semanticRecall`.
|
|
1849
|
+
|
|
1850
|
+
**Before:**
|
|
1851
|
+
|
|
1852
|
+
```typescript
|
|
1853
|
+
agent.stream('Hello', {
|
|
1854
|
+
memory: {
|
|
1855
|
+
thread: threadId,
|
|
1856
|
+
resource: resourceId,
|
|
1857
|
+
readOnly: true,
|
|
1858
|
+
},
|
|
1859
|
+
});
|
|
1860
|
+
```
|
|
1861
|
+
|
|
1862
|
+
**After:**
|
|
1863
|
+
|
|
1864
|
+
```typescript
|
|
1865
|
+
agent.stream('Hello', {
|
|
1866
|
+
memory: {
|
|
1867
|
+
thread: threadId,
|
|
1868
|
+
resource: resourceId,
|
|
1869
|
+
options: {
|
|
1870
|
+
readOnly: true,
|
|
1871
|
+
},
|
|
1872
|
+
},
|
|
1873
|
+
});
|
|
1874
|
+
```
|
|
1875
|
+
|
|
1876
|
+
**Migration:** Run the codemod to update your code automatically:
|
|
1877
|
+
|
|
1878
|
+
```shell
|
|
1879
|
+
npx @mastra/codemod@beta v1/memory-readonly-to-options .
|
|
1880
|
+
```
|
|
1881
|
+
|
|
1882
|
+
This also fixes issue #11519 where `readOnly: true` was being ignored and messages were saved to memory anyway.
|
|
1883
|
+
|
|
1884
|
+
- `getSpeakers` endpoint returns an empty array if voice is not configured on the agent and `getListeners` endpoint returns `{ enabled: false }` if voice is not figured on the agent. ([#10560](https://github.com/mastra-ai/mastra/pull/10560))
|
|
1885
|
+
|
|
1886
|
+
When no voice is set on agent don't throw error, by default set voice to undefined rather than DefaultVoice which throws errors when it is accessed.
|
|
1887
|
+
|
|
1888
|
+
- Auto resume suspended tools if `autoResumeSuspendedTools: true` ([#11157](https://github.com/mastra-ai/mastra/pull/11157))
|
|
1889
|
+
|
|
1890
|
+
The flag can be added to `defaultAgentOptions` when creating the agent or to options in `agent.stream` or `agent.generate`
|
|
1891
|
+
|
|
1892
|
+
```typescript
|
|
1893
|
+
const agent = new Agent({
|
|
1894
|
+
//...agent information,
|
|
1895
|
+
defaultAgentOptions: {
|
|
1896
|
+
autoResumeSuspendedTools: true,
|
|
1897
|
+
},
|
|
1898
|
+
});
|
|
1899
|
+
```
|
|
1900
|
+
|
|
1901
|
+
- Allow resuming nested workflow step with chained id ([#9459](https://github.com/mastra-ai/mastra/pull/9459))
|
|
1902
|
+
|
|
1903
|
+
Example, you have a workflow like this
|
|
1904
|
+
|
|
1905
|
+
```
|
|
1906
|
+
export const supportWorkflow = mainWorkflow.then(nestedWorkflow).commit();
|
|
1907
|
+
```
|
|
1908
|
+
|
|
1909
|
+
And a step in `nestedWorkflow` is supsended, you can now also resume it any of these ways:
|
|
1910
|
+
|
|
1911
|
+
```
|
|
1912
|
+
run.resume({
|
|
1913
|
+
step: "nestedWorkflow.suspendedStep", //chained nested workflow step id and suspended step id
|
|
1914
|
+
//other resume params
|
|
1915
|
+
})
|
|
1916
|
+
```
|
|
1917
|
+
|
|
1918
|
+
OR
|
|
1919
|
+
|
|
1920
|
+
```
|
|
1921
|
+
run.resume({
|
|
1922
|
+
step: "nestedWorkflow", // just the nested workflow step/step id
|
|
1923
|
+
//other resume params
|
|
1924
|
+
})
|
|
1925
|
+
```
|
|
1926
|
+
|
|
1927
|
+
- Preserve error details when thrown from workflow steps ([#10992](https://github.com/mastra-ai/mastra/pull/10992))
|
|
1928
|
+
- Errors thrown in workflow steps now preserve full error details including `cause` chain and custom properties
|
|
1929
|
+
- Added `SerializedError` type with proper cause chain support
|
|
1930
|
+
- Added `SerializedStepResult` and `SerializedStepFailure` types for handling errors loaded from storage
|
|
1931
|
+
- Enhanced `addErrorToJSON` to recursively serialize error cause chains with max depth protection
|
|
1932
|
+
- Added `hydrateSerializedStepErrors` to convert serialized errors back to Error instances
|
|
1933
|
+
- Fixed Inngest workflow error handling to extract original error from `NonRetriableError.cause`
|
|
1934
|
+
|
|
1935
|
+
- Fix base64 encoded images with threads - issue #10480 ([#10483](https://github.com/mastra-ai/mastra/pull/10483))
|
|
1936
|
+
|
|
1937
|
+
Fixed "Invalid URL" error when using base64 encoded images (without `data:` prefix) in agent calls with threads and resources. Raw base64 strings are now automatically converted to proper data URIs before being processed.
|
|
1938
|
+
|
|
1939
|
+
**Changes:**
|
|
1940
|
+
- Updated `attachments-to-parts.ts` to detect and convert raw base64 strings to data URIs
|
|
1941
|
+
- Fixed `MessageList` image processing to handle raw base64 in two locations:
|
|
1942
|
+
- Image part conversion in `aiV4CoreMessageToV1PromptMessage`
|
|
1943
|
+
- File part to experimental_attachments conversion in `mastraDBMessageToAIV4UIMessage`
|
|
1944
|
+
- Added comprehensive tests for base64 images, data URIs, and HTTP URLs with threads
|
|
1945
|
+
|
|
1946
|
+
**Breaking Change:** None - this is a bug fix that maintains backward compatibility while adding support for raw base64 strings.
|
|
1947
|
+
|
|
1948
|
+
- Fix OpenAI schema validation errors in processors ([#9093](https://github.com/mastra-ai/mastra/pull/9093))
|
|
1949
|
+
|
|
1950
|
+
- Fix dimension mismatch error when switching embedders in SemanticRecall. The processor now properly validates vector index dimensions when an index already exists, preventing runtime errors when switching between embedders with different dimensions (e.g., fastembed 384 dims → OpenAI 1536 dims). ([#11893](https://github.com/mastra-ai/mastra/pull/11893))
|
|
1951
|
+
|
|
1952
|
+
- SimpleAuth and improved CloudAuth ([#10490](https://github.com/mastra-ai/mastra/pull/10490))
|
|
1953
|
+
|
|
1954
|
+
- Move `@ai-sdk/azure` to devDependencies ([#10218](https://github.com/mastra-ai/mastra/pull/10218))
|
|
1955
|
+
|
|
1956
|
+
- When LLMs like Claude Sonnet 4.5 and Gemini 2.4 call tools with all-optional parameters, they send `args: undefined` instead of `args: {}`. This caused validation to fail with "root: Required". ([#10728](https://github.com/mastra-ai/mastra/pull/10728))
|
|
1957
|
+
|
|
1958
|
+
The fix normalizes `undefined`/`null` to `{}` for object schemas and `[]` for array schemas before validation.
|
|
1959
|
+
|
|
1960
|
+
- Removes the deprecated `threadId` and `resourceId` options from `AgentExecutionOptions`. These have been deprecated for months in favour of the `memory` option. ([#11897](https://github.com/mastra-ai/mastra/pull/11897))
|
|
1961
|
+
|
|
1962
|
+
### Breaking Changes
|
|
1963
|
+
|
|
1964
|
+
#### `@mastra/core`
|
|
1965
|
+
|
|
1966
|
+
The `threadId` and `resourceId` options have been removed from `agent.generate()` and `agent.stream()`. Use the `memory` option instead:
|
|
1967
|
+
|
|
1968
|
+
```ts
|
|
1969
|
+
// Before
|
|
1970
|
+
await agent.stream('Hello', {
|
|
1971
|
+
threadId: 'thread-123',
|
|
1972
|
+
resourceId: 'user-456',
|
|
1973
|
+
});
|
|
1974
|
+
|
|
1975
|
+
// After
|
|
1976
|
+
await agent.stream('Hello', {
|
|
1977
|
+
memory: {
|
|
1978
|
+
thread: 'thread-123',
|
|
1979
|
+
resource: 'user-456',
|
|
1980
|
+
},
|
|
1981
|
+
});
|
|
1982
|
+
```
|
|
1983
|
+
|
|
1984
|
+
#### `@mastra/server`
|
|
1985
|
+
|
|
1986
|
+
The `threadId`, `resourceId`, and `resourceid` fields have been removed from the main agent execution body schema. The server now expects the `memory` option format in request bodies. Legacy routes (`/api/agents/:agentId/generate-legacy` and `/api/agents/:agentId/stream-legacy`) continue to support the deprecated fields.
|
|
1987
|
+
|
|
1988
|
+
#### `@mastra/react`
|
|
1989
|
+
|
|
1990
|
+
The `useChat` hook now internally converts `threadId` to the `memory` option format when making API calls. No changes needed in component code - the hook handles the conversion automatically.
|
|
1991
|
+
|
|
1992
|
+
#### `@mastra/client-js`
|
|
1993
|
+
|
|
1994
|
+
When using the client SDK agent methods, use the `memory` option instead of `threadId`/`resourceId`:
|
|
1995
|
+
|
|
1996
|
+
```ts
|
|
1997
|
+
const agent = client.getAgent('my-agent');
|
|
1998
|
+
|
|
1999
|
+
// Before
|
|
2000
|
+
await agent.generate([...], {
|
|
2001
|
+
threadId: 'thread-123',
|
|
2002
|
+
resourceId: 'user-456',
|
|
2003
|
+
});
|
|
2004
|
+
|
|
2005
|
+
// After
|
|
2006
|
+
await agent.generate([...], {
|
|
2007
|
+
memory: {
|
|
2008
|
+
thread: 'thread-123',
|
|
2009
|
+
resource: 'user-456',
|
|
2010
|
+
},
|
|
2011
|
+
});
|
|
2012
|
+
```
|
|
2013
|
+
|
|
2014
|
+
- Loosen tools types in processInputStep / prepareStep. ([#11071](https://github.com/mastra-ai/mastra/pull/11071))
|
|
2015
|
+
|
|
2016
|
+
- Breaking change to move mcp related tool execute arguments nested under an `mcp` argument that is only populated if the tool is passed to an MCPServer. This simpliflies tool definitions and gives you the correct types when working with tools meant for MCP servers. ([#9134](https://github.com/mastra-ai/mastra/pull/9134))
|
|
2017
|
+
|
|
2018
|
+
- Refactor internal event system from Emitter to PubSub abstraction for workflow event handling. This change replaces the EventEmitter-based event system with a pluggable PubSub interface, enabling support for distributed workflow execution backends like Inngest. Adds `close()` method to PubSub implementations for proper cleanup. ([#11052](https://github.com/mastra-ai/mastra/pull/11052))
|
|
2019
|
+
|
|
2020
|
+
- Fix stopWhen type to accept AI SDK v6 StopCondition functions like `stepCountIs()` ([#11402](https://github.com/mastra-ai/mastra/pull/11402))
|
|
2021
|
+
|
|
2022
|
+
- Add human-in-the-loop (HITL) support to agent networks ([#11678](https://github.com/mastra-ai/mastra/pull/11678))
|
|
2023
|
+
- Add suspend/resume capabilities to agent network
|
|
2024
|
+
- Enable auto-resume for suspended network execution via `autoResumeSuspendedTools`
|
|
2025
|
+
|
|
2026
|
+
`agent.resumeNetwork`, `agent.approveNetworkToolCall`, `agent.declineNetworkToolCall`
|
|
2027
|
+
|
|
2028
|
+
- Fixed tool validation error messages so logs show Zod validation errors directly instead of hiding them inside structured JSON. ([#10579](https://github.com/mastra-ai/mastra/pull/10579))
|
|
2029
|
+
|
|
2030
|
+
- Add `startAsync()` method and fix Inngest duplicate workflow execution bug ([#11093](https://github.com/mastra-ai/mastra/pull/11093))
|
|
2031
|
+
|
|
2032
|
+
**New Feature: `startAsync()` for fire-and-forget workflow execution**
|
|
2033
|
+
- Add `Run.startAsync()` to base workflow class - starts workflow in background and returns `{ runId }` immediately
|
|
2034
|
+
- Add `EventedRun.startAsync()` - publishes workflow start event without subscribing for completion
|
|
2035
|
+
- Add `InngestRun.startAsync()` - sends Inngest event without polling for result
|
|
2036
|
+
|
|
2037
|
+
**Prevent duplicate Inngest workflow executions**
|
|
2038
|
+
- Fix `getRuns()` to properly handle rate limits (429), empty responses, and JSON parse errors with retry logic and exponential backoff
|
|
2039
|
+
- Fix `getRunOutput()` to throw `NonRetriableError` when polling fails, preventing Inngest from retrying the parent function and re-triggering the workflow
|
|
2040
|
+
- Add timeout to `getRunOutput()` polling (default 5 minutes) with `NonRetriableError` on timeout
|
|
2041
|
+
|
|
2042
|
+
This fixes a production issue where polling failures after successful workflow completion caused Inngest to retry the parent function, which fired a new workflow event and resulted in duplicate executions (e.g., duplicate Slack messages).
|
|
2043
|
+
|
|
2044
|
+
- Fixed AI SDK v6 provider tools (like `openai.tools.webSearch()`) not being invoked correctly. These tools are now properly recognized and executed instead of causing failures or hallucinated tool calls. ([#11946](https://github.com/mastra-ai/mastra/pull/11946))
|
|
2045
|
+
|
|
2046
|
+
Resolves `#11781`.
|
|
2047
|
+
|
|
2048
|
+
- Fix agent runs with multiple steps only showing last text chunk in observability tools ([#11672](https://github.com/mastra-ai/mastra/pull/11672))
|
|
2049
|
+
|
|
2050
|
+
When an agent model executes multiple steps and generates multiple text chunks, the onFinish payload was only receiving the text from the last step instead of all accumulated text. This caused observability tools like Braintrust to only display the final text chunk. The fix now correctly concatenates all text chunks from all steps.
|
|
2051
|
+
|
|
2052
|
+
- Adds validation guards to handle undefined/null values that can occur when config objects are spread (`{ ...config }`). Previously, if getters or non-enumerable properties resulted in undefined values during spread, the constructor would throw cryptic errors when accessing `.id` or `.name` on undefined objects. ([#10718](https://github.com/mastra-ai/mastra/pull/10718))
|
|
2053
|
+
|
|
2054
|
+
- Fix missing `title` field in Convex threads table schema ([#11356](https://github.com/mastra-ai/mastra/pull/11356))
|
|
2055
|
+
|
|
2056
|
+
The Convex schema was hardcoded and out of sync with the core `TABLE_SCHEMAS`, causing errors when creating threads:
|
|
2057
|
+
|
|
2058
|
+
```
|
|
2059
|
+
Error: Failed to insert or update a document in table "mastra_threads"
|
|
2060
|
+
because it does not match the schema: Object contains extra field `title`
|
|
2061
|
+
that is not in the validator.
|
|
2062
|
+
```
|
|
2063
|
+
|
|
2064
|
+
Now the Convex schema dynamically builds from `TABLE_SCHEMAS` via a new `@mastra/core/storage/constants` export path that doesn't pull in Node.js dependencies (safe for Convex's sandboxed schema evaluation).
|
|
2065
|
+
|
|
2066
|
+
```typescript
|
|
2067
|
+
// Users can now import schema tables without Node.js dependency issues
|
|
2068
|
+
import { mastraThreadsTable, mastraMessagesTable } from '@mastra/convex/schema';
|
|
2069
|
+
|
|
2070
|
+
export default defineSchema({
|
|
2071
|
+
mastra_threads: mastraThreadsTable,
|
|
2072
|
+
mastra_messages: mastraMessagesTable,
|
|
2073
|
+
});
|
|
2074
|
+
```
|
|
2075
|
+
|
|
2076
|
+
Fixes #11319
|
|
2077
|
+
|
|
2078
|
+
- Fix tool input validation destroying non-plain objects ([#11541](https://github.com/mastra-ai/mastra/pull/11541))
|
|
2079
|
+
|
|
2080
|
+
The `convertUndefinedToNull` function in tool input validation was treating all objects as plain objects and recursively processing them. For objects like `Date`, `Map`, `URL`, and class instances, this resulted in empty objects `{}` because they have no enumerable own properties.
|
|
2081
|
+
|
|
2082
|
+
This fix changes the approach to only recurse into plain objects (objects with `Object.prototype` or `null` prototype). All other objects (Date, Map, Set, URL, RegExp, Error, custom class instances, etc.) are now preserved as-is.
|
|
2083
|
+
|
|
2084
|
+
Fixes #11502
|
|
2085
|
+
|
|
2086
|
+
- Fixed an issue where deprecated Groq models were shown during template creation. The model selection now filters out models marked as deprecated, displaying only active and supported models. ([#11445](https://github.com/mastra-ai/mastra/pull/11445))
|
|
2087
|
+
|
|
2088
|
+
- Workaround for duplicate text-start/text-end IDs in multi-step agentic flows. ([#10740](https://github.com/mastra-ai/mastra/pull/10740))
|
|
2089
|
+
|
|
2090
|
+
The `@ai-sdk/anthropic` and `@ai-sdk/google` providers use numeric indices ("0", "1", etc.) for text block IDs that reset for each LLM call. This caused duplicate IDs when an agent does TEXT → TOOL → TEXT, breaking message ordering and storage.
|
|
2091
|
+
|
|
2092
|
+
The fix replaces numeric IDs with UUIDs, maintaining a map per step so text-start, text-delta, and text-end chunks for the same block share the same UUID. OpenAI's UUIDs pass through unchanged.
|
|
2093
|
+
|
|
2094
|
+
- Added support for AI SDK v6 embedding models (specification version v3) in memory and vector modules. Fixed TypeScript error where `ModelRouterEmbeddingModel` was trying to implement a union type instead of `EmbeddingModelV2` directly. ([#11362](https://github.com/mastra-ai/mastra/pull/11362))
|
|
2095
|
+
|
|
2096
|
+
- Fix empty overrideScorers causing error instead of skipping scoring ([#11257](https://github.com/mastra-ai/mastra/pull/11257))
|
|
2097
|
+
|
|
2098
|
+
When `overrideScorers` was passed as an empty object `{}`, the agent would throw a "No scorers found" error. Now an empty object explicitly skips scoring, while `undefined` continues to use default scorers.
|
|
2099
|
+
|
|
2100
|
+
- Fix GPT-5/o3 reasoning models failing with "required reasoning item" errors when using memory with tools. Empty reasoning is now stored with providerMetadata to preserve OpenAI's item_reference. ([#10585](https://github.com/mastra-ai/mastra/pull/10585))
|
|
2101
|
+
|
|
2102
|
+
- Fix generateTitle model type to accept AI SDK LanguageModelV2 ([#10541](https://github.com/mastra-ai/mastra/pull/10541))
|
|
2103
|
+
|
|
2104
|
+
Updated the `generateTitle.model` config option to accept `MastraModelConfig` instead of `MastraLanguageModel`. This allows users to pass raw AI SDK `LanguageModelV2` models (e.g., `anthropic.languageModel('claude-3-5-haiku-20241022')`) directly without type errors.
|
|
2105
|
+
|
|
2106
|
+
Previously, passing a standard `LanguageModelV2` would fail because `MastraLanguageModelV2` has different `doGenerate`/`doStream` return types. Now `MastraModelConfig` is used consistently across:
|
|
2107
|
+
- `memory/types.ts` - `generateTitle.model` config
|
|
2108
|
+
- `agent.ts` - `genTitle`, `generateTitleFromUserMessage`, `resolveTitleGenerationConfig`
|
|
2109
|
+
- `agent-legacy.ts` - `AgentLegacyCapabilities` interface
|
|
2110
|
+
|
|
2111
|
+
- fix: support gs:// and s3:// cloud storage URLs in attachmentsToParts ([#11398](https://github.com/mastra-ai/mastra/pull/11398))
|
|
2112
|
+
|
|
2113
|
+
- Some LLMs (particularly when not using native JSON mode) output actual newline characters inside JSON string values instead of properly escaped `\n` sequences. This breaks JSON parsing and causes structured output to fail. ([#10965](https://github.com/mastra-ai/mastra/pull/10965))
|
|
2114
|
+
|
|
2115
|
+
This change adds preprocessing to escape unescaped control characters (`\n`, `\r`, `\t`) within JSON string values before parsing, making structured output more robust across different LLM providers.
|
|
2116
|
+
|
|
2117
|
+
- Add validation to detect when a function is passed as a tool instead of a tool object. Previously, passing a tool factory function (e.g., `tools: { myTool }` instead of `tools: { myTool: myTool() }`) would silently fail - the LLM would request tool calls but nothing would execute. Now throws a clear error with guidance on how to fix it. ([#11288](https://github.com/mastra-ai/mastra/pull/11288))
|
|
2118
|
+
|
|
2119
|
+
- Fixed client-side tool invocations not being stored in memory. Previously, tool invocations with state 'call' were filtered out before persistence, which incorrectly removed client-side tools. Now only streaming intermediate states ('partial-call') are filtered. ([#11630](https://github.com/mastra-ai/mastra/pull/11630))
|
|
2120
|
+
|
|
2121
|
+
Fixed a crash when updating working memory with an empty or null update; existing data is now preserved.
|
|
2122
|
+
|
|
2123
|
+
- Fixed memory readOnly option not being respected when agents share a RequestContext. Previously, when output processors were resolved, the readOnly check happened too early - before the agent could set its own MastraMemory context. This caused child agents to inherit their parent's readOnly setting when sharing a RequestContext. ([#11653](https://github.com/mastra-ai/mastra/pull/11653))
|
|
2124
|
+
|
|
2125
|
+
The readOnly check is now only done at execution time in each processor's processOutputResult method, allowing proper isolation.
|
|
2126
|
+
|
|
2127
|
+
- Messages without `createdAt` timestamps were getting shuffled because they all received identical timestamps during conversion. Now messages are assigned monotonically increasing timestamps via `generateCreatedAt()`, preserving input order. ([#10686](https://github.com/mastra-ai/mastra/pull/10686))
|
|
2128
|
+
|
|
2129
|
+
Before:
|
|
2130
|
+
|
|
2131
|
+
```
|
|
2132
|
+
Input: [user: "hello", assistant: "Hi!", user: "bye"]
|
|
2133
|
+
Output: [user: "bye", assistant: "Hi!", user: "hello"] // shuffled!
|
|
2134
|
+
```
|
|
2135
|
+
|
|
2136
|
+
After:
|
|
2137
|
+
|
|
2138
|
+
```
|
|
2139
|
+
Input: [user: "hello", assistant: "Hi!", user: "bye"]
|
|
2140
|
+
Output: [user: "hello", assistant: "Hi!", user: "bye"] // correct order
|
|
2141
|
+
```
|
|
2142
|
+
|
|
2143
|
+
- fix(observability): start MODEL_STEP span at beginning of LLM execution ([#11409](https://github.com/mastra-ai/mastra/pull/11409))
|
|
2144
|
+
|
|
2145
|
+
The MODEL_STEP span was being created when the step-start chunk arrived (after the model API call completed), causing the span's startTime to be close to its endTime instead of accurately reflecting when the step began.
|
|
2146
|
+
|
|
2147
|
+
This fix ensures MODEL_STEP spans capture the full duration of each LLM execution step, including the API call latency, by starting the span at the beginning of the step execution rather than when the response starts streaming.
|
|
2148
|
+
|
|
2149
|
+
Fixes #11271
|
|
2150
|
+
|
|
2151
|
+
- Fix network validation not seeing previous iteration results in multi-step tasks ([#11691](https://github.com/mastra-ai/mastra/pull/11691))
|
|
2152
|
+
|
|
2153
|
+
The validation LLM was unable to determine task completion for multi-step tasks because it couldn't see what primitives had already executed. Now includes a compact list of completed primitives in the validation prompt.
|
|
2154
|
+
|
|
2155
|
+
- Fix tool outputSchema validation to allow unsupported Zod types like ZodTuple. The outputSchema is only used for internal validation and never sent to the LLM, so model compatibility checks are not needed. ([#9409](https://github.com/mastra-ai/mastra/pull/9409))
|
|
2156
|
+
|
|
2157
|
+
- Fix provider-executed tools (like `openai.tools.webSearch()`) not working correctly with AI SDK v6 models. The agent's `generate()` method was ending prematurely with `finishReason: 'tool-calls'` instead of completing with a text response after tool execution. ([#11622](https://github.com/mastra-ai/mastra/pull/11622))
|
|
2158
|
+
|
|
2159
|
+
The issue was that V6 provider tools have `type: 'provider'` while V5 uses `type: 'provider-defined'`. The tool preparation code now detects the model version and uses the correct type.
|
|
2160
|
+
|
|
2161
|
+
- Fix reasoning providerMetadata leaking into text parts when using memory with OpenAI reasoning models. The runState.providerOptions is now cleared after reasoning-end to prevent text parts from inheriting the reasoning's itemId. ([#11380](https://github.com/mastra-ai/mastra/pull/11380))
|
|
2162
|
+
|
|
2163
|
+
- Scorers now have access to custom gateways when resolving models. Previously, calling `resolveModelConfig` in the scorer didn't pass the Mastra instance, so custom gateways were never available. ([#10778](https://github.com/mastra-ai/mastra/pull/10778))
|
|
2164
|
+
|
|
2165
|
+
- Ensure model_generation spans end before agent_run spans. ([#9251](https://github.com/mastra-ai/mastra/pull/9251))
|
|
2166
|
+
|
|
2167
|
+
- Sub-agents with dynamic model configurations were broken because `requestContext` was not being passed to `getModel()` when creating agent tools. This caused sub-agents using function-based model configurations to receive an empty context instead of the parent's context. ([#10844](https://github.com/mastra-ai/mastra/pull/10844))
|
|
2168
|
+
|
|
2169
|
+
No code changes required for consumers - this fix restores expected behavior for dynamic model configurations in sub-agents.
|
|
2170
|
+
|
|
2171
|
+
- Fixed `TokenLimiterProcessor` not filtering memory messages when limiting tokens. ([#11941](https://github.com/mastra-ai/mastra/pull/11941))
|
|
2172
|
+
|
|
2173
|
+
Previously, the processor only received the latest user input messages, missing the conversation history from memory. This meant token limiting couldn't filter historical messages to fit within the context window.
|
|
2174
|
+
|
|
2175
|
+
The processor now correctly:
|
|
2176
|
+
- Accesses all messages (memory + input) when calculating token budgets
|
|
2177
|
+
- Accounts for system messages in the token budget
|
|
2178
|
+
- Filters older messages to prioritize recent conversation context
|
|
2179
|
+
|
|
2180
|
+
Fixes #11902
|
|
2181
|
+
|
|
2182
|
+
- Fixed inline type narrowing for `tool.execute()` return type when using `outputSchema`. ([#11420](https://github.com/mastra-ai/mastra/pull/11420))
|
|
2183
|
+
|
|
2184
|
+
**Problem:** When calling `tool.execute()`, TypeScript couldn't narrow the `ValidationError | OutputType` union after checking `'error' in result && result.error`, causing type errors when accessing output properties.
|
|
2185
|
+
|
|
2186
|
+
**Solution:**
|
|
2187
|
+
- Added `{ error?: never }` to the success type, enabling proper discriminated union narrowing
|
|
2188
|
+
- Simplified `createTool` generics so `inputData` is correctly typed based on `inputSchema`
|
|
2189
|
+
|
|
2190
|
+
**Note:** Tool output schemas should not use `error` as a field name since it's reserved for ValidationError discrimination. Use `errorMessage` or similar instead.
|
|
2191
|
+
|
|
2192
|
+
**Usage:**
|
|
2193
|
+
|
|
2194
|
+
```typescript
|
|
2195
|
+
const result = await myTool.execute({ firstName: 'Hans' });
|
|
2196
|
+
|
|
2197
|
+
if ('error' in result && result.error) {
|
|
2198
|
+
console.error('Validation failed:', result.message);
|
|
2199
|
+
return;
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
// ✅ TypeScript now correctly narrows result
|
|
2203
|
+
return { fullName: result.fullName };
|
|
2204
|
+
```
|
|
2205
|
+
|
|
2206
|
+
- Fix toolCallId propagation in agent network tool execution. The toolCallId property was undefined at runtime despite being required by TypeScript type definitions in AgentToolExecutionContext. Now properly passes the toolCallId through to the tool's context during network tool execution. ([#10951](https://github.com/mastra-ai/mastra/pull/10951))
|
|
2207
|
+
|
|
2208
|
+
- Changes `ToolStream` to extend `WritableStream<unknown>` instead of `WritableStream<T>`. This fixes the TypeScript error when piping `objectStream` or `fullStream` to `writer` in workflow steps. ([#10845](https://github.com/mastra-ai/mastra/pull/10845))
|
|
2209
|
+
|
|
2210
|
+
Before:
|
|
2211
|
+
|
|
2212
|
+
```typescript
|
|
2213
|
+
// TypeError: ToolStream<ChunkType> is not assignable to WritableStream<Partial<StoryPlan>>
|
|
2214
|
+
await response.objectStream.pipeTo(writer);
|
|
2215
|
+
```
|
|
2216
|
+
|
|
2217
|
+
After:
|
|
2218
|
+
|
|
2219
|
+
```typescript
|
|
2220
|
+
// Works without type errors
|
|
2221
|
+
await response.objectStream.pipeTo(writer);
|
|
2222
|
+
```
|
|
2223
|
+
|
|
2224
|
+
- Fix AI SDK v6 (specificationVersion: "v3") model support in sub-agent calls. Previously, when a parent agent invoked a sub-agent with a v3 model through the `agents` property, the version check only matched "v2", causing v3 models to incorrectly fall back to legacy streaming methods and throw "V2 models are not supported for streamLegacy" error. ([#11452](https://github.com/mastra-ai/mastra/pull/11452))
|
|
2225
|
+
|
|
2226
|
+
The fix updates version checks in `listAgentTools` and `llm-mapping-step.ts` to use the centralized `supportedLanguageModelSpecifications` array which includes both v2 and v3.
|
|
2227
|
+
|
|
2228
|
+
Also adds missing v3 test coverage to tool-handling.test.ts to prevent regression.
|
|
2229
|
+
|
|
2230
|
+
- Ensure that when resuming a workflow from a snapshot, the input property is correctly set from the snapshot's context input rather than from resume data. This prevents the loss of original workflow input data during suspend/resume cycles. ([#9380](https://github.com/mastra-ai/mastra/pull/9380))
|
|
2231
|
+
|
|
2232
|
+
- When createRun is called with an existing runId, it now correctly updates the run's status from the storage snapshot. This fixes the issue where different workflow instances (e.g., different API requests) would get a run with 'pending' status instead of the correct status from storage (e.g., 'suspended'). ([#10664](https://github.com/mastra-ai/mastra/pull/10664))
|
|
2233
|
+
|
|
2234
|
+
- Fixed "Transforms cannot be represented in JSON Schema" error when using Zod v4 with structuredOutput ([#11466](https://github.com/mastra-ai/mastra/pull/11466))
|
|
2235
|
+
|
|
2236
|
+
When using schemas with `.optional()`, `.nullable()`, `.default()`, or `.nullish().default("")` patterns with `structuredOutput` and Zod v4, users would encounter an error because OpenAI schema compatibility layer adds transforms that Zod v4's native `toJSONSchema()` cannot handle.
|
|
2237
|
+
|
|
2238
|
+
The fix uses Mastra's transform-safe `zodToJsonSchema` function which gracefully handles transforms by using the `unrepresentable: 'any'` option.
|
|
2239
|
+
|
|
2240
|
+
Also exported `isZodType` utility from `@mastra/schema-compat` and updated it to detect both Zod v3 (`_def`) and Zod v4 (`_zod`) schemas.
|
|
2241
|
+
|
|
2242
|
+
- Fix crash in `mastraDBMessageToAIV4UIMessage` when `content.parts` is undefined or null. ([#11550](https://github.com/mastra-ai/mastra/pull/11550))
|
|
2243
|
+
|
|
2244
|
+
This resolves an issue where `ModerationProcessor` (and other code paths using `MessageList.get.*.ui()`) would throw `TypeError: Cannot read properties of undefined (reading 'length')` when processing messages with missing `parts` array. This commonly occurred when using AI SDK v4 (LanguageModelV1) models with input/output processors.
|
|
2245
|
+
|
|
2246
|
+
The fix adds null coalescing (`?? []`) to safely handle undefined/null `parts` in the message conversion method.
|
|
2247
|
+
|
|
2248
|
+
- Upgrade AI SDK v6 from beta to stable (6.0.1) and fix finishReason breaking change. ([#11351](https://github.com/mastra-ai/mastra/pull/11351))
|
|
2249
|
+
|
|
2250
|
+
AI SDK v6 stable changed finishReason from a string to an object with `unified` and `raw` properties. Added `normalizeFinishReason()` helper to handle both v5 (string) and v6 (object) formats at the stream transform layer
|
|
2251
|
+
|
|
2252
|
+
- Improve autoResumeSuspendedTools instruction for tool approval ([#11338](https://github.com/mastra-ai/mastra/pull/11338))
|
|
2253
|
+
|
|
2254
|
+
- Fix vector definition to fix pinecone ([#10150](https://github.com/mastra-ai/mastra/pull/10150))
|
|
2255
|
+
|
|
2256
|
+
- Preserve error details when thrown from workflow steps ([#10992](https://github.com/mastra-ai/mastra/pull/10992))
|
|
2257
|
+
|
|
2258
|
+
Workflow errors now retain custom properties like `statusCode`, `responseHeaders`, and `cause` chains. This enables error-specific recovery logic in your applications.
|
|
2259
|
+
|
|
2260
|
+
**Before:**
|
|
2261
|
+
|
|
2262
|
+
```typescript
|
|
2263
|
+
const result = await workflow.execute({ input });
|
|
2264
|
+
if (result.status === 'failed') {
|
|
2265
|
+
// Custom error properties were lost
|
|
2266
|
+
console.log(result.error); // "Step execution failed" (just a string)
|
|
2267
|
+
}
|
|
2268
|
+
```
|
|
2269
|
+
|
|
2270
|
+
**After:**
|
|
2271
|
+
|
|
2272
|
+
```typescript
|
|
2273
|
+
const result = await workflow.execute({ input });
|
|
2274
|
+
if (result.status === 'failed') {
|
|
2275
|
+
// Custom properties are preserved
|
|
2276
|
+
console.log(result.error.message); // "Step execution failed"
|
|
2277
|
+
console.log(result.error.statusCode); // 429
|
|
2278
|
+
console.log(result.error.cause?.name); // "RateLimitError"
|
|
2279
|
+
}
|
|
2280
|
+
```
|
|
2281
|
+
|
|
2282
|
+
**Type change:** `WorkflowState.error` and `WorkflowRunState.error` types changed from `string | Error` to `SerializedError`.
|
|
2283
|
+
|
|
2284
|
+
Other changes:
|
|
2285
|
+
- Added `UpdateWorkflowStateOptions` type for workflow state updates
|
|
2286
|
+
|
|
2287
|
+
- Fix message metadata not persisting when using simple message format. Previously, custom metadata passed in messages (e.g., `{role: 'user', content: 'text', metadata: {userId: '123'}}`) was not being saved to the database. This occurred because the CoreMessage conversion path didn't preserve metadata fields. ([#10488](https://github.com/mastra-ai/mastra/pull/10488))
|
|
2288
|
+
|
|
2289
|
+
Now metadata is properly preserved for all message input formats:
|
|
2290
|
+
- Simple CoreMessage format: `{role, content, metadata}`
|
|
2291
|
+
- Full UIMessage format: `{role, content, parts, metadata}`
|
|
2292
|
+
- AI SDK v5 ModelMessage format with metadata
|
|
2293
|
+
|
|
2294
|
+
Fixes #8556
|
|
2295
|
+
|
|
2296
|
+
- Fix Zod 4 compatibility for storage schema detection ([#11431](https://github.com/mastra-ai/mastra/pull/11431))
|
|
2297
|
+
|
|
2298
|
+
If you're using Zod 4, `buildStorageSchema` was failing to detect nullable and optional fields correctly. This caused `NOT NULL constraint failed` errors when storing observability spans and other data.
|
|
2299
|
+
|
|
2300
|
+
This fix enables proper schema detection for Zod 4 users, ensuring nullable fields like `parentSpanId` are correctly identified and don't cause database constraint violations.
|
|
2301
|
+
|
|
2302
|
+
- Add native Perplexity provider support ([#10885](https://github.com/mastra-ai/mastra/pull/10885))
|
|
2303
|
+
|
|
2304
|
+
- Added `startExclusive` and `endExclusive` options to `dateRange` filter for message queries. ([#11479](https://github.com/mastra-ai/mastra/pull/11479))
|
|
2305
|
+
|
|
2306
|
+
**What changed:** The `filter.dateRange` parameter in `listMessages()` and `Memory.recall()` now supports `startExclusive` and `endExclusive` boolean options. When set to `true`, messages with timestamps exactly matching the boundary are excluded from results.
|
|
2307
|
+
|
|
2308
|
+
**Why this matters:** Enables cursor-based pagination for chat applications. When new messages arrive during a session, offset-based pagination can skip or duplicate messages. Using `endExclusive: true` with the oldest message's timestamp as a cursor ensures consistent pagination without gaps or duplicates.
|
|
2309
|
+
|
|
2310
|
+
**Example:**
|
|
2311
|
+
|
|
2312
|
+
```typescript
|
|
2313
|
+
// Get first page
|
|
2314
|
+
const page1 = await memory.recall({
|
|
2315
|
+
threadId: 'thread-123',
|
|
2316
|
+
perPage: 10,
|
|
2317
|
+
orderBy: { field: 'createdAt', direction: 'DESC' },
|
|
2318
|
+
});
|
|
2319
|
+
|
|
2320
|
+
// Get next page using cursor-based pagination
|
|
2321
|
+
const oldestMessage = page1.messages[page1.messages.length - 1];
|
|
2322
|
+
const page2 = await memory.recall({
|
|
2323
|
+
threadId: 'thread-123',
|
|
2324
|
+
perPage: 10,
|
|
2325
|
+
orderBy: { field: 'createdAt', direction: 'DESC' },
|
|
2326
|
+
filter: {
|
|
2327
|
+
dateRange: {
|
|
2328
|
+
end: oldestMessage.createdAt,
|
|
2329
|
+
endExclusive: true, // Excludes the cursor message
|
|
2330
|
+
},
|
|
2331
|
+
},
|
|
2332
|
+
});
|
|
2333
|
+
```
|
|
2334
|
+
|
|
2335
|
+
- Improved TypeScript type inference for workflow steps. ([#11953](https://github.com/mastra-ai/mastra/pull/11953))
|
|
2336
|
+
|
|
2337
|
+
**What changed:**
|
|
2338
|
+
- Step input/output type mismatches are now caught at compile time when chaining steps with `.then()`
|
|
2339
|
+
- The `execute` function now properly infers types from `inputSchema`, `outputSchema`, `stateSchema`, and other schema parameters
|
|
2340
|
+
- Clearer error messages when step types don't match workflow requirements
|
|
2341
|
+
|
|
2342
|
+
**Why:**
|
|
2343
|
+
Previously, type errors in workflow step chains would only surface at runtime. Now TypeScript validates that each step's input requirements are satisfied by the previous step's output, helping you catch integration issues earlier in development.
|
|
2344
|
+
|
|
2345
|
+
- Fix Zod 4 compatibility issue with structuredOutput in agent.generate() ([#11133](https://github.com/mastra-ai/mastra/pull/11133))
|
|
2346
|
+
|
|
2347
|
+
Users with Zod 4 installed would see `TypeError: undefined is not an object (evaluating 'def.valueType._zod')` when using `structuredOutput` with agent.generate(). This happened because ProcessorStepSchema contains `z.custom()` fields that hold user-provided Zod schemas, and the workflow validation was trying to deeply validate these schemas causing version conflicts.
|
|
2348
|
+
|
|
2349
|
+
The fix disables input validation for processor workflows since `z.custom()` fields are meant to pass through arbitrary types without deep validation.
|
|
2350
|
+
|
|
2351
|
+
- Truncate map config when too long ([#11175](https://github.com/mastra-ai/mastra/pull/11175))
|
|
2352
|
+
|
|
2353
|
+
- fix resumeStream type to use resumeSchema ([#10202](https://github.com/mastra-ai/mastra/pull/10202))
|
|
2354
|
+
|
|
2355
|
+
- Pass resourceId and threadId to network agent's subAgent when it has its own memory ([#10592](https://github.com/mastra-ai/mastra/pull/10592))
|
|
2356
|
+
|
|
2357
|
+
- use `agent.getMemory` to fetch the memory instance on the Agent class to make sure that storage gets set if memory doesn't set it itself. ([#10556](https://github.com/mastra-ai/mastra/pull/10556))
|
|
2358
|
+
|
|
2359
|
+
- Built-in processors that use internal agents (PromptInjectionDetector, ModerationProcessor, PIIDetector, LanguageDetector, StructuredOutputProcessor) now accept `providerOptions` to control model behavior. ([#10651](https://github.com/mastra-ai/mastra/pull/10651))
|
|
2360
|
+
|
|
2361
|
+
This lets you pass provider-specific settings like `reasoningEffort` for OpenAI thinking models:
|
|
2362
|
+
|
|
2363
|
+
```typescript
|
|
2364
|
+
const processor = new PromptInjectionDetector({
|
|
2365
|
+
model: 'openai/o1-mini',
|
|
2366
|
+
threshold: 0.7,
|
|
2367
|
+
strategy: 'block',
|
|
2368
|
+
providerOptions: {
|
|
2369
|
+
openai: {
|
|
2370
|
+
reasoningEffort: 'low',
|
|
2371
|
+
},
|
|
2372
|
+
},
|
|
2373
|
+
});
|
|
2374
|
+
```
|
|
2375
|
+
|
|
2376
|
+
- Improved typing for `workflow.then` to allow the provided steps `inputSchema` to be a subset of the previous steps `outputSchema`. Also errors if the provided steps `inputSchema` is a superset of the previous steps outputSchema. ([#10763](https://github.com/mastra-ai/mastra/pull/10763))
|
|
2377
|
+
|
|
2378
|
+
- Composite auth implementation ([#10359](https://github.com/mastra-ai/mastra/pull/10359))
|
|
2379
|
+
|
|
2380
|
+
- Fix message list provider metadata handling and reasoning text optimization ([#10281](https://github.com/mastra-ai/mastra/pull/10281))
|
|
2381
|
+
- Improved provider metadata preservation across message transformations
|
|
2382
|
+
- Optimized reasoning text storage to avoid duplication (using `details` instead of `reasoning` field)
|
|
2383
|
+
- Fixed test snapshots for timestamp precision and metadata handling
|
|
2384
|
+
|
|
2385
|
+
- Fix requireApproval property being ignored for tools passed via toolsets, clientTools, and memoryTools parameters. The requireApproval flag now correctly propagates through all tool conversion paths, ensuring tools requiring approval will properly request user approval before execution. ([#10464](https://github.com/mastra-ai/mastra/pull/10464))
|
|
2386
|
+
|
|
2387
|
+
- fix(core): support LanguageModelV3 in MastraModelGateway.resolveLanguageModel ([#11489](https://github.com/mastra-ai/mastra/pull/11489))
|
|
2388
|
+
|
|
2389
|
+
- Fixed duplicate storage initialization when init() is called explicitly before other methods. The augmentWithInit proxy now tracks when init() is called directly, preventing subsequent method calls from triggering init() again. This resolves the high volume of requests to storage backends (like Turso) during agent streaming with memory enabled. ([#12067](https://github.com/mastra-ai/mastra/pull/12067))
|
|
2390
|
+
|
|
2391
|
+
- Add timeTravel APIs and add timeTravel feature to studio ([#10361](https://github.com/mastra-ai/mastra/pull/10361))
|
|
2392
|
+
|
|
2393
|
+
- Add helpful JSDoc comments to `BundlerConfig` properties (used with `bundler` option) ([#10218](https://github.com/mastra-ai/mastra/pull/10218))
|
|
2394
|
+
|
|
2395
|
+
- Improve type handling with Zod ([#12091](https://github.com/mastra-ai/mastra/pull/12091))
|
|
2396
|
+
|
|
2397
|
+
- Added the ability to provide a base path for Mastra Studio. ([#10441](https://github.com/mastra-ai/mastra/pull/10441))
|
|
2398
|
+
|
|
2399
|
+
```ts
|
|
2400
|
+
import { Mastra } from '@mastra/core';
|
|
2401
|
+
|
|
2402
|
+
export const mastra = new Mastra({
|
|
2403
|
+
server: {
|
|
2404
|
+
studioBase: '/my-mastra-studio',
|
|
2405
|
+
},
|
|
2406
|
+
});
|
|
2407
|
+
```
|
|
2408
|
+
|
|
2409
|
+
This will make Mastra Studio available at `http://localhost:4111/my-mastra-studio`.
|
|
2410
|
+
|
|
2411
|
+
- Fix Azure Foundry rate limit handling for -1 values ([#10409](https://github.com/mastra-ai/mastra/pull/10409))
|
|
2412
|
+
|
|
2413
|
+
- Improve error messaging for LLM API errors. When an error originates from an LLM provider (e.g., rate limits, overloaded, auth failures), the console now indicates it's an upstream API error and includes the provider and model information. ([#12022](https://github.com/mastra-ai/mastra/pull/12022))
|
|
2414
|
+
|
|
2415
|
+
Before:
|
|
2416
|
+
|
|
2417
|
+
```
|
|
2418
|
+
ERROR (Mastra): Error in agent stream
|
|
2419
|
+
error: { "message": "Overloaded", "type": "overloaded_error" }
|
|
2420
|
+
```
|
|
2421
|
+
|
|
2422
|
+
After:
|
|
2423
|
+
|
|
2424
|
+
```
|
|
2425
|
+
ERROR (Mastra): Upstream LLM API error from anthropic (model: claude-3-opus)
|
|
2426
|
+
error: { "message": "Overloaded", "type": "overloaded_error" }
|
|
2427
|
+
```
|
|
2428
|
+
|
|
2429
|
+
- feat: Add field filtering and nested workflow control to workflow execution result endpoint ([#11246](https://github.com/mastra-ai/mastra/pull/11246))
|
|
2430
|
+
|
|
2431
|
+
Adds two optional query parameters to `/api/workflows/:workflowId/runs/:runId/execution-result` endpoint:
|
|
2432
|
+
- `fields`: Request only specific fields (e.g., `status`, `result`, `error`)
|
|
2433
|
+
- `withNestedWorkflows`: Control whether to fetch nested workflow data
|
|
2434
|
+
|
|
2435
|
+
This significantly reduces response payload size and improves response times for large workflows.
|
|
2436
|
+
|
|
2437
|
+
## Server Endpoint Usage
|
|
2438
|
+
|
|
2439
|
+
```http
|
|
2440
|
+
# Get only status (minimal payload - fastest)
|
|
2441
|
+
GET /api/workflows/:workflowId/runs/:runId/execution-result?fields=status
|
|
2442
|
+
|
|
2443
|
+
# Get status and result
|
|
2444
|
+
GET /api/workflows/:workflowId/runs/:runId/execution-result?fields=status,result
|
|
2445
|
+
|
|
2446
|
+
# Get all fields but without nested workflow data (faster)
|
|
2447
|
+
GET /api/workflows/:workflowId/runs/:runId/execution-result?withNestedWorkflows=false
|
|
2448
|
+
|
|
2449
|
+
# Get only specific fields without nested workflow data
|
|
2450
|
+
GET /api/workflows/:workflowId/runs/:runId/execution-result?fields=status,steps&withNestedWorkflows=false
|
|
2451
|
+
|
|
2452
|
+
# Get full data (default behavior)
|
|
2453
|
+
GET /api/workflows/:workflowId/runs/:runId/execution-result
|
|
2454
|
+
```
|
|
2455
|
+
|
|
2456
|
+
## Client SDK Usage
|
|
2457
|
+
|
|
2458
|
+
```typescript
|
|
2459
|
+
import { MastraClient } from '@mastra/client-js';
|
|
2460
|
+
|
|
2461
|
+
const client = new MastraClient({ baseUrl: 'http://localhost:4111' });
|
|
2462
|
+
const workflow = client.getWorkflow('myWorkflow');
|
|
2463
|
+
|
|
2464
|
+
// Get only status (minimal payload - fastest)
|
|
2465
|
+
const statusOnly = await workflow.runExecutionResult(runId, {
|
|
2466
|
+
fields: ['status'],
|
|
2467
|
+
});
|
|
2468
|
+
console.log(statusOnly.status); // 'success' | 'failed' | 'running' | etc.
|
|
2469
|
+
|
|
2470
|
+
// Get status and result
|
|
2471
|
+
const statusAndResult = await workflow.runExecutionResult(runId, {
|
|
2472
|
+
fields: ['status', 'result'],
|
|
2473
|
+
});
|
|
2474
|
+
|
|
2475
|
+
// Get all fields but without nested workflow data (faster)
|
|
2476
|
+
const resultWithoutNested = await workflow.runExecutionResult(runId, {
|
|
2477
|
+
withNestedWorkflows: false,
|
|
2478
|
+
});
|
|
2479
|
+
|
|
2480
|
+
// Get specific fields without nested workflow data
|
|
2481
|
+
const optimized = await workflow.runExecutionResult(runId, {
|
|
2482
|
+
fields: ['status', 'steps'],
|
|
2483
|
+
withNestedWorkflows: false,
|
|
2484
|
+
});
|
|
2485
|
+
|
|
2486
|
+
// Get full execution result (default behavior)
|
|
2487
|
+
const fullResult = await workflow.runExecutionResult(runId);
|
|
2488
|
+
```
|
|
2489
|
+
|
|
2490
|
+
## Core API Changes
|
|
2491
|
+
|
|
2492
|
+
The `Workflow.getWorkflowRunExecutionResult` method now accepts an options object:
|
|
2493
|
+
|
|
2494
|
+
```typescript
|
|
2495
|
+
await workflow.getWorkflowRunExecutionResult(runId, {
|
|
2496
|
+
withNestedWorkflows: false, // default: true, set to false to skip nested workflow data
|
|
2497
|
+
fields: ['status', 'result'], // optional field filtering
|
|
2498
|
+
});
|
|
2499
|
+
```
|
|
2500
|
+
|
|
2501
|
+
## Inngest Compatibility
|
|
2502
|
+
|
|
2503
|
+
The `@mastra/inngest` package has been updated to use the new options object API. This is a non-breaking internal change - no action required from inngest workflow users.
|
|
2504
|
+
|
|
2505
|
+
## Performance Impact
|
|
2506
|
+
|
|
2507
|
+
For workflows with large step outputs:
|
|
2508
|
+
- Requesting only `status`: ~99% reduction in payload size
|
|
2509
|
+
- Requesting `status,result,error`: ~95% reduction in payload size
|
|
2510
|
+
- Using `withNestedWorkflows=false`: Avoids expensive nested workflow data fetching
|
|
2511
|
+
- Combining both: Maximum performance optimization
|
|
2512
|
+
|
|
2513
|
+
- Fix model headers not being passed through gateway system ([#10465](https://github.com/mastra-ai/mastra/pull/10465))
|
|
2514
|
+
|
|
2515
|
+
Previously, custom headers specified in `MastraModelConfig` were not being passed through the gateway system to model providers. This affected:
|
|
2516
|
+
- OpenRouter (preventing activity tracking with `HTTP-Referer` and `X-Title`)
|
|
2517
|
+
- Custom providers using custom URLs (headers not passed to `createOpenAICompatible`)
|
|
2518
|
+
- Custom gateway implementations (headers not available in `resolveLanguageModel`)
|
|
2519
|
+
|
|
2520
|
+
Now headers are correctly passed through the entire gateway system:
|
|
2521
|
+
- Base `MastraModelGateway` interface updated to accept headers
|
|
2522
|
+
- `ModelRouterLanguageModel` passes headers from config to all gateways
|
|
2523
|
+
- OpenRouter receives headers for activity tracking
|
|
2524
|
+
- Custom URL providers receive headers via `createOpenAICompatible`
|
|
2525
|
+
- Custom gateways can access headers in their `resolveLanguageModel` implementation
|
|
2526
|
+
|
|
2527
|
+
Example usage:
|
|
2528
|
+
|
|
2529
|
+
```typescript
|
|
2530
|
+
// Works with OpenRouter
|
|
2531
|
+
const agent = new Agent({
|
|
2532
|
+
name: 'my-agent',
|
|
2533
|
+
instructions: 'You are a helpful assistant.',
|
|
2534
|
+
model: {
|
|
2535
|
+
id: 'openrouter/anthropic/claude-3-5-sonnet',
|
|
2536
|
+
headers: {
|
|
2537
|
+
'HTTP-Referer': 'https://myapp.com',
|
|
2538
|
+
'X-Title': 'My Application',
|
|
2539
|
+
},
|
|
2540
|
+
},
|
|
2541
|
+
});
|
|
2542
|
+
|
|
2543
|
+
// Also works with custom providers
|
|
2544
|
+
const customAgent = new Agent({
|
|
2545
|
+
name: 'custom-agent',
|
|
2546
|
+
instructions: 'You are a helpful assistant.',
|
|
2547
|
+
model: {
|
|
2548
|
+
id: 'custom-provider/model',
|
|
2549
|
+
url: 'https://api.custom.com/v1',
|
|
2550
|
+
apiKey: 'key',
|
|
2551
|
+
headers: {
|
|
2552
|
+
'X-Custom-Header': 'custom-value',
|
|
2553
|
+
},
|
|
2554
|
+
},
|
|
2555
|
+
});
|
|
2556
|
+
```
|
|
2557
|
+
|
|
2558
|
+
Fixes https://github.com/mastra-ai/mastra/issues/9760
|
|
2559
|
+
|
|
2560
|
+
- Add type bailed to workflowRunStatus ([#10091](https://github.com/mastra-ai/mastra/pull/10091))
|
|
2561
|
+
|
|
2562
|
+
- Add tool call approval ([#8649](https://github.com/mastra-ai/mastra/pull/8649))
|
|
2563
|
+
|
|
2564
|
+
- Fixed a bug where multiple tools streaming output simultaneously could fail with "WritableStreamDefaultWriter is locked" errors. Tool streaming now works reliably during concurrent tool executions. ([#10830](https://github.com/mastra-ai/mastra/pull/10830))
|
|
2565
|
+
|
|
2566
|
+
- default validate inputs to true in Workflow execute ([#10222](https://github.com/mastra-ai/mastra/pull/10222))
|
|
2567
|
+
|
|
2568
|
+
- Fixes issues where thread and messages were not saved before suspension when tools require approval or call suspend() during execution. This caused conversation history to be lost if users refreshed during tool approval or suspension. ([#10369](https://github.com/mastra-ai/mastra/pull/10369))
|
|
2569
|
+
|
|
2570
|
+
**Backend changes (@mastra/core):**
|
|
2571
|
+
- Add assistant messages to messageList immediately after LLM execution
|
|
2572
|
+
- Flush messages synchronously before suspension to persist state
|
|
2573
|
+
- Create thread if it doesn't exist before flushing
|
|
2574
|
+
- Add metadata helpers to persist and remove tool approval state
|
|
2575
|
+
- Pass saveQueueManager and memory context through workflow for immediate persistence
|
|
2576
|
+
|
|
2577
|
+
**Frontend changes (@mastra/react):**
|
|
2578
|
+
- Extract runId from pending approvals to enable resumption after refresh
|
|
2579
|
+
- Convert `pendingToolApprovals` (DB format) to `requireApprovalMetadata` (runtime format)
|
|
2580
|
+
- Handle both `dynamic-tool` and `tool-{NAME}` part types for approval state
|
|
2581
|
+
- Change runId from hardcoded `agentId` to unique `uuid()`
|
|
2582
|
+
|
|
2583
|
+
**UI changes (@mastra/playground-ui):**
|
|
2584
|
+
- Handle tool calls awaiting approval in message initialization
|
|
2585
|
+
- Convert approval metadata format when loading initial messages
|
|
2586
|
+
|
|
2587
|
+
Fixes #9745, #9906
|
|
2588
|
+
|
|
2589
|
+
- Fix error handling and serialization in agent streaming to ensure errors are consistently exposed and preserved. ([#9144](https://github.com/mastra-ai/mastra/pull/9144))
|
|
2590
|
+
|
|
2591
|
+
- Update MockMemory to work with new storage API changes. MockMemory now properly implements all abstract MastraMemory methods. This includes proper thread management, message saving with MessageList conversion, working memory operations with scope support, and resource listing. ([#10368](https://github.com/mastra-ai/mastra/pull/10368))
|
|
2592
|
+
|
|
2593
|
+
Add Zod v4 support for working memory schemas. Memory implementations now check for Zod v4's built-in `.toJsonSchema()` method before falling back to the `zodToJsonSchema` compatibility function, improving performance and forward compatibility while maintaining backward compatibility with Zod v3.
|
|
2594
|
+
|
|
2595
|
+
Add Gemini 3 Pro test coverage in agent-gemini.test.ts to validate the latest Gemini model integration.
|
|
2596
|
+
|
|
2597
|
+
- Fixes issue where clicking the reset button in the model picker would fail to restore the original LanguageModelV2 (or any other types) object that was passed during agent construction. ([#9481](https://github.com/mastra-ai/mastra/pull/9481))
|
|
2598
|
+
|
|
2599
|
+
- Fix a bug where streaming didn't output the final chunk ([#9546](https://github.com/mastra-ai/mastra/pull/9546))
|
|
2600
|
+
|
|
2601
|
+
- Expand `processInputStep` processor method and integrate `prepareStep` as a processor ([#10774](https://github.com/mastra-ai/mastra/pull/10774))
|
|
2602
|
+
|
|
2603
|
+
**New Features:**
|
|
2604
|
+
- `prepareStep` callback now runs through the standard `processInputStep` pipeline
|
|
2605
|
+
- Processors can now modify per-step: `model`, `tools`, `toolChoice`, `activeTools`, `messages`, `systemMessages`, `providerOptions`, `modelSettings`, and `structuredOutput`
|
|
2606
|
+
- Processor chaining: each processor receives accumulated state from previous processors
|
|
2607
|
+
- System messages are isolated per-step (reset at start of each step)
|
|
2608
|
+
|
|
2609
|
+
**Breaking Change:**
|
|
2610
|
+
- `prepareStep` messages format changed from AI SDK v5 model messages to `MastraDBMessage` format
|
|
2611
|
+
- Migration: Use `messageList.get.all.aiV5.model()` if you need the old format
|
|
2612
|
+
|
|
2613
|
+
- Fix type issue with workflow `.parallel()` when passing multiple steps, one or more of which has a `resumeSchema` provided. ([#10708](https://github.com/mastra-ai/mastra/pull/10708))
|
|
2614
|
+
|
|
2615
|
+
- Add support for `instructions` field in MCPServer ([#11421](https://github.com/mastra-ai/mastra/pull/11421))
|
|
2616
|
+
|
|
2617
|
+
Implements the official MCP specification's `instructions` field, which allows MCP servers to provide system-wide prompts that are automatically sent to clients during initialization. This eliminates the need for per-project configuration files (like AGENTS.md) by centralizing the system prompt in the server definition.
|
|
2618
|
+
|
|
2619
|
+
**What's New:**
|
|
2620
|
+
- Added `instructions` optional field to `MCPServerConfig` type
|
|
2621
|
+
- Instructions are passed to the underlying MCP SDK Server during initialization
|
|
2622
|
+
- Instructions are sent to clients in the `InitializeResult` response
|
|
2623
|
+
- Fully compatible with all MCP clients (Cursor, Windsurf, Claude Desktop, etc.)
|
|
2624
|
+
|
|
2625
|
+
**Example Usage:**
|
|
2626
|
+
|
|
2627
|
+
```typescript
|
|
2628
|
+
const server = new MCPServer({
|
|
2629
|
+
name: 'GitHub MCP Server',
|
|
2630
|
+
version: '1.0.0',
|
|
2631
|
+
instructions:
|
|
2632
|
+
'Use the available tools to help users manage GitHub repositories, issues, and pull requests. Always search before creating to avoid duplicates.',
|
|
2633
|
+
tools: { searchIssues, createIssue, listPRs },
|
|
2634
|
+
});
|
|
2635
|
+
```
|
|
2636
|
+
|
|
2637
|
+
- Fix race condition in parallel tool stream writes ([#10463](https://github.com/mastra-ai/mastra/pull/10463))
|
|
2638
|
+
|
|
2639
|
+
Introduces a write queue to ToolStream to serialize access to the underlying stream, preventing writer locked errors
|
|
2640
|
+
|
|
2641
|
+
- Remove unneeded console warning when flushing messages and no threadId or saveQueueManager is found. ([#10498](https://github.com/mastra-ai/mastra/pull/10498))
|
|
2642
|
+
|
|
2643
|
+
- Don't call `os.homedir()` at top level (but lazy invoke it) to accommodate sandboxed environments ([#9211](https://github.com/mastra-ai/mastra/pull/9211))
|
|
2644
|
+
|
|
2645
|
+
- Don't download unsupported media ([#9209](https://github.com/mastra-ai/mastra/pull/9209))
|
|
2646
|
+
|
|
2647
|
+
- Add support for doGenerate in LanguageModelV2. This change fixes issues with OpenAI stream permissions. ([#10239](https://github.com/mastra-ai/mastra/pull/10239))
|
|
2648
|
+
- Added new abstraction over LanguageModelV2
|
|
2649
|
+
|
|
2650
|
+
- Add storage composition to MastraStorage ([#11401](https://github.com/mastra-ai/mastra/pull/11401))
|
|
2651
|
+
|
|
2652
|
+
`MastraStorage` can now compose storage domains from different adapters. Use it when you need different databases for different purposes - for example, PostgreSQL for memory and workflows, but a different database for observability.
|
|
2653
|
+
|
|
2654
|
+
```typescript
|
|
2655
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
2656
|
+
import { MemoryPG, WorkflowsPG, ScoresPG } from '@mastra/pg';
|
|
2657
|
+
import { MemoryLibSQL } from '@mastra/libsql';
|
|
2658
|
+
|
|
2659
|
+
// Compose domains from different stores
|
|
2660
|
+
const storage = new MastraStorage({
|
|
2661
|
+
id: 'composite',
|
|
2662
|
+
domains: {
|
|
2663
|
+
memory: new MemoryLibSQL({ url: 'file:./local.db' }),
|
|
2664
|
+
workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
|
|
2665
|
+
scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
|
|
2666
|
+
},
|
|
2667
|
+
});
|
|
2668
|
+
```
|
|
2669
|
+
|
|
2670
|
+
**Breaking changes:**
|
|
2671
|
+
- `storage.supports` property no longer exists
|
|
2672
|
+
- `StorageSupports` type is no longer exported from `@mastra/core/storage`
|
|
2673
|
+
|
|
2674
|
+
All stores now support the same features. For domain availability, use `getStore()`:
|
|
2675
|
+
|
|
2676
|
+
```typescript
|
|
2677
|
+
const store = await storage.getStore('memory');
|
|
2678
|
+
if (store) {
|
|
2679
|
+
// domain is available
|
|
2680
|
+
}
|
|
2681
|
+
```
|
|
2682
|
+
|
|
2683
|
+
- Fixes .network() method ignores MASTRA_RESOURCE_ID_KEY from requestContext ([`4524734`](https://github.com/mastra-ai/mastra/commit/45247343e384717a7c8404296275c56201d6470f))
|
|
2684
|
+
|
|
2685
|
+
- Fixed the type of targetResult in the onItemComplete callback for runEvals. The parameter was incorrectly typed as a Promise, but the actual value passed is already resolved. Users no longer need to await targetResult inside their callback. ([#12030](https://github.com/mastra-ai/mastra/pull/12030))
|
|
2686
|
+
|
|
2687
|
+
- Detect thenable objects returned by AI model providers ([#8905](https://github.com/mastra-ai/mastra/pull/8905))
|
|
2688
|
+
|
|
2689
|
+
- - PostgreSQL: use `getSqlType()` in `createTable` instead of `toUpperCase()` ([#11112](https://github.com/mastra-ai/mastra/pull/11112))
|
|
2690
|
+
- LibSQL: use `getSqlType()` in `createTable`, return `JSONB` for jsonb type (matches SQLite 3.45+ support)
|
|
2691
|
+
- ClickHouse: use `getSqlType()` in `createTable` instead of `COLUMN_TYPES` constant, add missing types (uuid, float, boolean)
|
|
2692
|
+
- Remove unused `getSqlType()` and `getDefaultValue()` from `MastraStorage` base class (all stores use `StoreOperations` versions)
|
|
2693
|
+
|
|
2694
|
+
- Fixed agent network not returning text response when routing agent handles requests without delegation. ([#11497](https://github.com/mastra-ai/mastra/pull/11497))
|
|
2695
|
+
|
|
2696
|
+
**What changed:**
|
|
2697
|
+
- Agent networks now correctly stream text responses when the routing agent decides to handle a request itself instead of delegating to sub-agents, workflows, or tools
|
|
2698
|
+
- Added fallback in transformers to ensure text is always returned even if core events are missing
|
|
2699
|
+
|
|
2700
|
+
**Why this matters:**
|
|
2701
|
+
Previously, when using `toAISdkV5Stream` or `networkRoute()` outside of the Mastra Studio UI, no text content was returned when the routing agent handled requests directly. This fix ensures consistent behavior across all API routes.
|
|
2702
|
+
|
|
2703
|
+
Fixes #11219
|
|
2704
|
+
|
|
2705
|
+
- chore(core): MessageHistory input processor pass resourceId for storage ([#11910](https://github.com/mastra-ai/mastra/pull/11910))
|
|
2706
|
+
|
|
2707
|
+
- Add debugger-like click-through UI to workflow graph ([#11350](https://github.com/mastra-ai/mastra/pull/11350))
|
|
2708
|
+
|
|
2709
|
+
- Adds bidirectional integration with otel tracing via a new @mastra/otel-bridge package. ([#10482](https://github.com/mastra-ai/mastra/pull/10482))
|
|
2710
|
+
|
|
2711
|
+
- Add delete workflow run API ([#10991](https://github.com/mastra-ai/mastra/pull/10991))
|
|
2712
|
+
|
|
2713
|
+
```typescript
|
|
2714
|
+
await workflow.deleteWorkflowRunById(runId);
|
|
2715
|
+
```
|
|
2716
|
+
|
|
2717
|
+
- Add optional includeRawChunks parameter to agent execution options, ([#10456](https://github.com/mastra-ai/mastra/pull/10456))
|
|
2718
|
+
allowing users to include raw chunks in stream output where supported
|
|
2719
|
+
by the model provider.
|
|
2720
|
+
|
|
2721
|
+
- Add initial state input to workflow form in studio ([#11560](https://github.com/mastra-ai/mastra/pull/11560))
|
|
2722
|
+
|
|
2723
|
+
- Fix input tool validation when no inputSchema is provided ([#9941](https://github.com/mastra-ai/mastra/pull/9941))
|
|
2724
|
+
|
|
2725
|
+
- When `mastra dev` runs, multiple processes can write to `provider-registry.json` concurrently (auto-refresh, syncGateways, syncGlobalCacheToLocal). This causes file corruption where the end of the JSON appears twice, making it unparseable. ([#10455](https://github.com/mastra-ai/mastra/pull/10455))
|
|
2726
|
+
|
|
2727
|
+
The fix uses atomic writes via the write-to-temp-then-rename pattern. Instead of:
|
|
2728
|
+
|
|
2729
|
+
```ts
|
|
2730
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
2731
|
+
```
|
|
2732
|
+
|
|
2733
|
+
We now do:
|
|
2734
|
+
|
|
2735
|
+
```ts
|
|
2736
|
+
const tempPath = `${filePath}.${process.pid}.${Date.now()}.${randomSuffix}.tmp`;
|
|
2737
|
+
fs.writeFileSync(tempPath, content, 'utf-8');
|
|
2738
|
+
fs.renameSync(tempPath, filePath); // atomic on POSIX
|
|
2739
|
+
```
|
|
2740
|
+
|
|
2741
|
+
`fs.rename()` is atomic on POSIX systems when both paths are on the same filesystem, so concurrent writes will each complete fully rather than interleaving.
|
|
2742
|
+
|
|
2743
|
+
- Adds `processInputStep` method to the Processor interface. Unlike `processInput` which runs once at the start, this runs at each step of the agentic loop (including tool call continuations). ([#10650](https://github.com/mastra-ai/mastra/pull/10650))
|
|
2744
|
+
|
|
2745
|
+
```ts
|
|
2746
|
+
const processor: Processor = {
|
|
2747
|
+
id: 'my-processor',
|
|
2748
|
+
processInputStep: async ({ messages, messageList, stepNumber, systemMessages }) => {
|
|
2749
|
+
// Transform messages at each step before LLM call
|
|
2750
|
+
return messageList;
|
|
2751
|
+
},
|
|
2752
|
+
};
|
|
2753
|
+
```
|
|
2754
|
+
|
|
2755
|
+
- Added missing stream types to @mastra/core/stream for better TypeScript support ([#11513](https://github.com/mastra-ai/mastra/pull/11513))
|
|
2756
|
+
|
|
2757
|
+
**New types available:**
|
|
2758
|
+
- Chunk types: `ToolCallChunk`, `ToolResultChunk`, `SourceChunk`, `FileChunk`, `ReasoningChunk`
|
|
2759
|
+
- Payload types: `ToolCallPayload`, `ToolResultPayload`, `TextDeltaPayload`, `ReasoningDeltaPayload`, `FilePayload`, `SourcePayload`
|
|
2760
|
+
- JSON utilities: `JSONValue`, `JSONObject`, `JSONArray` and readonly variants
|
|
2761
|
+
|
|
2762
|
+
These types are now properly exported, enabling full TypeScript IntelliSense when working with streaming data.
|
|
2763
|
+
|
|
2764
|
+
- - `Run.cancel()` now updates workflow status to 'canceled' in storage, resolving the issue where suspended workflows remained in 'suspended' status after cancellation ([#11139](https://github.com/mastra-ai/mastra/pull/11139))
|
|
2765
|
+
- Cancellation status is immediately persisted and reflected to observers
|
|
2766
|
+
|
|
2767
|
+
- When using output processors with `agent.generate()`, `result.text` was returning the unprocessed LLM response instead of the processed text. ([#10735](https://github.com/mastra-ai/mastra/pull/10735))
|
|
2768
|
+
|
|
2769
|
+
**Before:**
|
|
2770
|
+
|
|
2771
|
+
```ts
|
|
2772
|
+
const result = await agent.generate('hello');
|
|
2773
|
+
result.text; // "hello world" (unprocessed)
|
|
2774
|
+
result.response.messages[0].content[0].text; // "HELLO WORLD" (processed)
|
|
2775
|
+
```
|
|
2776
|
+
|
|
2777
|
+
**After:**
|
|
2778
|
+
|
|
2779
|
+
```ts
|
|
2780
|
+
const result = await agent.generate('hello');
|
|
2781
|
+
result.text; // "HELLO WORLD" (processed)
|
|
2782
|
+
```
|
|
2783
|
+
|
|
2784
|
+
The bug was caused by the `text` delayed promise being resolved twice - first correctly with the processed text, then overwritten with the unprocessed buffered text.
|
|
2785
|
+
|
|
2786
|
+
- Add `response` to finish chunk payload for output processor metadata access ([#11549](https://github.com/mastra-ai/mastra/pull/11549))
|
|
2787
|
+
|
|
2788
|
+
When using output processors with streaming, metadata added via `processOutputResult` is now accessible in the finish chunk's `payload.response.uiMessages`. This allows clients consuming streams over HTTP (e.g., via `/stream/ui`) to access processor-added metadata.
|
|
2789
|
+
|
|
2790
|
+
```typescript
|
|
2791
|
+
for await (const chunk of stream.fullStream) {
|
|
2792
|
+
if (chunk.type === 'finish') {
|
|
2793
|
+
const uiMessages = chunk.payload.response?.uiMessages;
|
|
2794
|
+
const metadata = uiMessages?.find(m => m.role === 'assistant')?.metadata;
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
```
|
|
2798
|
+
|
|
2799
|
+
Fixes #11454
|
|
2800
|
+
|
|
2801
|
+
- Make initialState optional in studio ([#11744](https://github.com/mastra-ai/mastra/pull/11744))
|
|
2802
|
+
|
|
2803
|
+
- Refactored default engine to fit durable execution better, and the inngest engine to match. ([#10627](https://github.com/mastra-ai/mastra/pull/10627))
|
|
2804
|
+
Also fixes requestContext persistence by relying on inngest step memoization.
|
|
2805
|
+
|
|
2806
|
+
Unifies some of the stepResults and error formats in both engines.
|
|
2807
|
+
|
|
2808
|
+
- Removed a debug log that printed large Zod schemas, resulting in cleaner console output when using agents with memory enabled. ([#11279](https://github.com/mastra-ai/mastra/pull/11279))
|
|
2809
|
+
|
|
2810
|
+
- Fix type recursion by importing from 'zod' instead of 'zod/v3' ([#12009](https://github.com/mastra-ai/mastra/pull/12009))
|
|
2811
|
+
|
|
2812
|
+
- Fixed formatting of model_step, model_chunk, and tool_call spans in Arize Exporter. ([#11922](https://github.com/mastra-ai/mastra/pull/11922))
|
|
2813
|
+
|
|
2814
|
+
Also removed `tools` output from `model_step` spans for all exporters.
|
|
2815
|
+
|
|
2816
|
+
- Set `externals: true` as the default for `mastra build` and cloud-deployer to reduce bundle issues with native dependencies. ([`0dbf199`](https://github.com/mastra-ai/mastra/commit/0dbf199110f22192ce5c95b1c8148d4872b4d119))
|
|
2817
|
+
|
|
2818
|
+
**Note:** If you previously relied on the default bundling behavior (all dependencies bundled), you can explicitly set `externals: false` in your bundler configuration.
|
|
2819
|
+
|
|
2820
|
+
- Fixes incorrect tool invocation format in message list that was causing client tools to fail during message format conversions. ([#9590](https://github.com/mastra-ai/mastra/pull/9590))
|
|
2821
|
+
|
|
2822
|
+
- Allow direct access to server app handle directly from Mastra instance. ([#10598](https://github.com/mastra-ai/mastra/pull/10598))
|
|
2823
|
+
|
|
2824
|
+
```ts
|
|
2825
|
+
// Before: HTTP request to localhost
|
|
2826
|
+
const response = await fetch(`http://localhost:5000/api/tools`);
|
|
2827
|
+
|
|
2828
|
+
// After: Direct call via app.fetch()
|
|
2829
|
+
const app = mastra.getServerApp<Hono>();
|
|
2830
|
+
const response = await app.fetch(new Request('http://internal/api/tools'));
|
|
2831
|
+
```
|
|
2832
|
+
|
|
2833
|
+
- Added `mastra.getServerApp<T>()` to access the underlying Hono/Express app
|
|
2834
|
+
- Added `mastra.getMastraServer()` and `mastra.setMastraServer()` for adapter access
|
|
2835
|
+
- Added `MastraServerBase` class in `@mastra/core/server` for adapter implementations
|
|
2836
|
+
- Server adapters now auto-register with Mastra in their constructor
|
|
2837
|
+
|
|
2838
|
+
- Allow provider to pass through options to the auth config ([#10284](https://github.com/mastra-ai/mastra/pull/10284))
|
|
2839
|
+
|
|
2840
|
+
- When sending the first message to a new thread with PostgresStore, users would get a "Thread not found" error. This happened because the thread was created in memory but not persisted to the database before the MessageHistory output processor tried to save messages. ([#10881](https://github.com/mastra-ai/mastra/pull/10881))
|
|
2841
|
+
|
|
2842
|
+
**Before:**
|
|
2843
|
+
|
|
2844
|
+
```ts
|
|
2845
|
+
threadObject = await memory.createThread({
|
|
2846
|
+
// ...
|
|
2847
|
+
saveThread: false, // thread not in DB yet
|
|
2848
|
+
});
|
|
2849
|
+
// Later: MessageHistory calls saveMessages() -> PostgresStore throws "Thread not found"
|
|
2850
|
+
```
|
|
2851
|
+
|
|
2852
|
+
**After:**
|
|
2853
|
+
|
|
2854
|
+
```ts
|
|
2855
|
+
threadObject = await memory.createThread({
|
|
2856
|
+
// ...
|
|
2857
|
+
saveThread: true, // thread persisted immediately
|
|
2858
|
+
});
|
|
2859
|
+
// MessageHistory can now save messages without error
|
|
2860
|
+
```
|
|
2861
|
+
|
|
2862
|
+
- Fix network agent not getting `text-delta` from subAgent when `.stream` is used ([#10533](https://github.com/mastra-ai/mastra/pull/10533))
|
|
2863
|
+
|
|
2864
|
+
- Fix .map when placed at the beginning of a workflow or nested workflow ([#10457](https://github.com/mastra-ai/mastra/pull/10457))
|
|
2865
|
+
|
|
2866
|
+
- Fix various places in core package where we were logging with console.error instead of the mastra logger. ([#11425](https://github.com/mastra-ai/mastra/pull/11425))
|
|
2867
|
+
|
|
2868
|
+
- Use input processors that are passed in generate or stream agent options rather than always defaulting to the processors set on the Agent class. ([#9407](https://github.com/mastra-ai/mastra/pull/9407))
|
|
2869
|
+
|
|
2870
|
+
- Add `perStep` option to workflow run methods, allowing a workflow to run just a step instead of all the workflow steps ([#11276](https://github.com/mastra-ai/mastra/pull/11276))
|
|
2871
|
+
|
|
2872
|
+
- Previously, tool input validation used the original Zod schema while the LLM received a schema-compat transformed version. This caused validation failures when LLMs (like OpenAI o3 or Claude 3.5 Haiku) sent arguments matching the transformed schema but not the original. ([#9258](https://github.com/mastra-ai/mastra/pull/9258))
|
|
2873
|
+
|
|
2874
|
+
For example:
|
|
2875
|
+
- OpenAI o3 reasoning models convert `.optional()` to `.nullable()`, sending `null` values
|
|
2876
|
+
- Claude 3.5 Haiku strips `min`/`max` string constraints, sending shorter strings
|
|
2877
|
+
- Validation would reject these valid responses because it checked against the original schema
|
|
2878
|
+
|
|
2879
|
+
The fix ensures validation uses the same schema-compat processed schema that was sent to the LLM, eliminating this mismatch.
|
|
2880
|
+
|
|
2881
|
+
- Improved tracing by filtering infrastructure chunks from model streams and adding success attribute to tool spans. ([#11943](https://github.com/mastra-ai/mastra/pull/11943))
|
|
2882
|
+
|
|
2883
|
+
Added generic input/output attribute mapping for additional span types in Arize exporter.
|
|
2884
|
+
|
|
2885
|
+
- Add import for WriteableStream in execution-engine and dedupe llm.getModel in agent.ts ([#9185](https://github.com/mastra-ai/mastra/pull/9185))
|
|
2886
|
+
|
|
2887
|
+
- Fix deprecation warning when agent network executes workflows by using `.fullStream` instead of iterating `WorkflowRunOutput` directly ([#10285](https://github.com/mastra-ai/mastra/pull/10285))
|
|
2888
|
+
|
|
2889
|
+
- Internal refactor to `MessageList` for improved maintainability and modularity. This change does not affect external APIs or functionality. ([#11658](https://github.com/mastra-ai/mastra/pull/11658))
|
|
2890
|
+
|
|
2891
|
+
- Ensures that data chunks written via `writer.custom()` always bubble up directly to the top-level stream, even when nested in sub-agents. This allows tools to emit custom progress updates, metrics, and other data that can be consumed at any level of the agent hierarchy. ([#10309](https://github.com/mastra-ai/mastra/pull/10309))
|
|
2892
|
+
- **Added bubbling logic in sub-agent execution**: When sub-agents execute, data chunks (chunks with type starting with `data-`) are detected and written via `writer.custom()` instead of `writer.write()`, ensuring they bubble up directly without being wrapped in `tool-output` chunks.
|
|
2893
|
+
- **Added comprehensive tests**:
|
|
2894
|
+
- Test for `writer.custom()` with direct tool execution
|
|
2895
|
+
- Test for `writer.custom()` with sub-agent tools (nested execution)
|
|
2896
|
+
- Test for mixed usage of `writer.write()` and `writer.custom()` in the same tool
|
|
2897
|
+
|
|
2898
|
+
When a sub-agent's tool uses `writer.custom()` to write data chunks, those chunks appear in the sub-agent's stream. The parent agent's execution logic now detects these chunks and uses `writer.custom()` to bubble them up directly, preserving their structure and making them accessible at the top level.
|
|
2899
|
+
|
|
2900
|
+
This ensures that:
|
|
2901
|
+
- Data chunks from tools always appear directly in the stream (not wrapped)
|
|
2902
|
+
- Data chunks bubble up correctly through nested agent hierarchies
|
|
2903
|
+
- Regular chunks continue to be wrapped in `tool-output` as expected
|
|
2904
|
+
|
|
2905
|
+
- Emit error chunk and call onError when agent workflow step fails ([#10907](https://github.com/mastra-ai/mastra/pull/10907))
|
|
2906
|
+
|
|
2907
|
+
When a workflow step fails (e.g., tool not found), the error is now properly emitted as an error chunk to the stream and the onError callback is called. This fixes the issue where agent.generate() would throw "promise 'text' was not resolved or rejected" instead of the actual error message.
|
|
2908
|
+
|
|
2909
|
+
- Fix discriminatedUnion schema information lost when json schema is converted to zod ([#10500](https://github.com/mastra-ai/mastra/pull/10500))
|
|
2910
|
+
|
|
2911
|
+
- `setState` is now async ([#10944](https://github.com/mastra-ai/mastra/pull/10944))
|
|
2912
|
+
- `setState` must now be awaited: `await setState({ key: value })`
|
|
2913
|
+
- State updates are merged automatically—no need to spread the previous state
|
|
2914
|
+
- State data is validated against the step's `stateSchema` when `validateInputs` is enabled (default: `true`)
|
|
2915
|
+
|
|
2916
|
+
- Use agent description when converting agent to tool ([#10879](https://github.com/mastra-ai/mastra/pull/10879))
|
|
2917
|
+
|
|
2918
|
+
- Fix generate toolResults and mismatch in provider tool names ([#10282](https://github.com/mastra-ai/mastra/pull/10282))
|
|
2919
|
+
|
|
2920
|
+
- Adds ability to create custom `MastraModelGateway`'s that can be added to the `Mastra` class instance under the `gateways` property. Giving you typescript autocompletion in any model picker string. ([#10180](https://github.com/mastra-ai/mastra/pull/10180))
|
|
2921
|
+
|
|
2922
|
+
```typescript
|
|
2923
|
+
import { MastraModelGateway, type ProviderConfig } from '@mastra/core/llm';
|
|
2924
|
+
import { createOpenAICompatible } from '@ai-sdk/openai-compatible-v5';
|
|
2925
|
+
import type { LanguageModelV2 } from '@ai-sdk/provider-v5';
|
|
2926
|
+
|
|
2927
|
+
class MyCustomGateway extends MastraModelGateway {
|
|
2928
|
+
readonly id = 'my-custom-gateway';
|
|
2929
|
+
readonly name = 'My Custom Gateway';
|
|
2930
|
+
readonly prefix = 'custom';
|
|
2931
|
+
|
|
2932
|
+
async fetchProviders(): Promise<Record<string, ProviderConfig>> {
|
|
2933
|
+
return {
|
|
2934
|
+
'my-provider': {
|
|
2935
|
+
name: 'My Provider',
|
|
2936
|
+
models: ['model-1', 'model-2'],
|
|
2937
|
+
apiKeyEnvVar: 'MY_API_KEY',
|
|
2938
|
+
gateway: this.id,
|
|
2939
|
+
},
|
|
2940
|
+
};
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
buildUrl(modelId: string, envVars?: Record<string, string>): string {
|
|
2944
|
+
return 'https://api.my-provider.com/v1';
|
|
2945
|
+
}
|
|
2946
|
+
|
|
2947
|
+
async getApiKey(modelId: string): Promise<string> {
|
|
2948
|
+
const apiKey = process.env.MY_API_KEY;
|
|
2949
|
+
if (!apiKey) throw new Error('MY_API_KEY not set');
|
|
2950
|
+
return apiKey;
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
async resolveLanguageModel({
|
|
2954
|
+
modelId,
|
|
2955
|
+
providerId,
|
|
2956
|
+
apiKey,
|
|
2957
|
+
}: {
|
|
2958
|
+
modelId: string;
|
|
2959
|
+
providerId: string;
|
|
2960
|
+
apiKey: string;
|
|
2961
|
+
}): Promise<LanguageModelV2> {
|
|
2962
|
+
const baseURL = this.buildUrl(`${providerId}/${modelId}`);
|
|
2963
|
+
return createOpenAICompatible({
|
|
2964
|
+
name: providerId,
|
|
2965
|
+
apiKey,
|
|
2966
|
+
baseURL,
|
|
2967
|
+
}).chatModel(modelId);
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
new Mastra({
|
|
2972
|
+
gateways: {
|
|
2973
|
+
myGateway: new MyCustomGateway(),
|
|
2974
|
+
},
|
|
2975
|
+
});
|
|
2976
|
+
```
|
|
2977
|
+
|
|
2978
|
+
- Support AI SDK voice models ([#10304](https://github.com/mastra-ai/mastra/pull/10304))
|
|
2979
|
+
|
|
2980
|
+
Mastra now supports AI SDK's transcription and speech models directly in `CompositeVoice`, enabling seamless integration with a wide range of voice providers through the AI SDK ecosystem. This allows you to use models from OpenAI, ElevenLabs, Groq, Deepgram, LMNT, Hume, and many more for both speech-to-text (transcription) and text-to-speech capabilities.
|
|
2981
|
+
|
|
2982
|
+
AI SDK models are automatically wrapped when passed to `CompositeVoice`, so you can mix and match AI SDK models with existing Mastra voice providers for maximum flexibility.
|
|
2983
|
+
|
|
2984
|
+
**Usage Example**
|
|
2985
|
+
|
|
2986
|
+
```typescript
|
|
2987
|
+
import { CompositeVoice } from '@mastra/core/voice';
|
|
2988
|
+
import { openai } from '@ai-sdk/openai';
|
|
2989
|
+
import { elevenlabs } from '@ai-sdk/elevenlabs';
|
|
2990
|
+
|
|
2991
|
+
// Use AI SDK models directly with CompositeVoice
|
|
2992
|
+
const voice = new CompositeVoice({
|
|
2993
|
+
input: openai.transcription('whisper-1'), // AI SDK transcription model
|
|
2994
|
+
output: elevenlabs.speech('eleven_turbo_v2'), // AI SDK speech model
|
|
2995
|
+
});
|
|
2996
|
+
|
|
2997
|
+
// Convert text to speech
|
|
2998
|
+
const audioStream = await voice.speak('Hello from AI SDK!');
|
|
2999
|
+
|
|
3000
|
+
// Convert speech to text
|
|
3001
|
+
const transcript = await voice.listen(audioStream);
|
|
3002
|
+
console.log(transcript);
|
|
3003
|
+
```
|
|
3004
|
+
|
|
3005
|
+
Fixes #9947
|
|
3006
|
+
|
|
3007
|
+
- Refactor: consolidate duplicate applyMessages helpers in workflow.ts ([#11688](https://github.com/mastra-ai/mastra/pull/11688))
|
|
3008
|
+
- Added optional `defaultSource` parameter to `ProcessorRunner.applyMessagesToMessageList` to support both 'input' and 'response' default sources
|
|
3009
|
+
- Removed 3 duplicate inline `applyMessages` helper functions from workflow.ts (in input, outputResult, and outputStep phases)
|
|
3010
|
+
- All phases now use the shared `ProcessorRunner.applyMessagesToMessageList` static method
|
|
3011
|
+
|
|
3012
|
+
This is an internal refactoring with no changes to external behavior.
|
|
3013
|
+
|
|
3014
|
+
- Resolve suspendPayload when tripwire is set off in agentic loop to prevent unresolved promises hanging. ([#11621](https://github.com/mastra-ai/mastra/pull/11621))
|
|
3015
|
+
|
|
3016
|
+
- Use a shared `getAllToolPaths()` method from the bundler to discover tool paths. ([#9204](https://github.com/mastra-ai/mastra/pull/9204))
|
|
3017
|
+
|
|
3018
|
+
- Add an additional check to determine whether the model natively supports specific file types. Only download the file if the model does not support it natively. ([#9790](https://github.com/mastra-ai/mastra/pull/9790))
|
|
3019
|
+
|
|
3020
|
+
- Fix OpenAI reasoning model + memory failing on second generate with "missing item" error ([#11492](https://github.com/mastra-ai/mastra/pull/11492))
|
|
3021
|
+
|
|
3022
|
+
When using OpenAI reasoning models with memory enabled, the second `agent.generate()` call would fail with: "Item 'rs\_...' of type 'reasoning' was provided without its required following item."
|
|
3023
|
+
|
|
3024
|
+
The issue was that `text-start` events contain `providerMetadata` with the text's `itemId` (e.g., `msg_xxx`), but this metadata was not being captured. When memory replayed the conversation, the reasoning part had its `rs_` ID but the text part was missing its `msg_` ID, causing OpenAI to reject the request.
|
|
3025
|
+
|
|
3026
|
+
The fix adds handlers for `text-start` (to capture text providerMetadata) and `text-end` (to clear it and prevent leaking into subsequent parts).
|
|
3027
|
+
|
|
3028
|
+
Fixes #11481
|
|
3029
|
+
|
|
3030
|
+
- Update agent workflow and sub-agent tool transformations to accept more input arguments. ([#10278](https://github.com/mastra-ai/mastra/pull/10278))
|
|
3031
|
+
|
|
3032
|
+
These tools now accept the following
|
|
3033
|
+
|
|
3034
|
+
```ts
|
|
3035
|
+
workflowTool.execute({ inputData, initialState }, context);
|
|
3036
|
+
|
|
3037
|
+
agentTool.execute({ prompt, threadId, resourceId, instructions, maxSteps }, context);
|
|
3038
|
+
```
|
|
3039
|
+
|
|
3040
|
+
Workflow tools now also properly return errors when the workflow run fails
|
|
3041
|
+
|
|
3042
|
+
```ts
|
|
3043
|
+
const workflowResult = await workflowTool.execute({ inputData, initialState }, context);
|
|
3044
|
+
|
|
3045
|
+
console.log(workflowResult.error); // error msg if error
|
|
3046
|
+
console.log(workflowResult.result); // result of the workflow if success
|
|
3047
|
+
```
|
|
3048
|
+
|
|
3049
|
+
Workflows passed to agents do not properly handle suspend/resume`, they only handle success or error.
|
|
3050
|
+
|
|
3051
|
+
- Fixed OpenAI schema compatibility when using `agent.generate()` or `agent.stream()` with `structuredOutput`. ([#10366](https://github.com/mastra-ai/mastra/pull/10366))
|
|
3052
|
+
|
|
3053
|
+
**Changes**
|
|
3054
|
+
- **Automatic transformation**: Zod schemas are now automatically transformed for OpenAI strict mode compatibility when using OpenAI models (including reasoning models like o1, o3, o4)
|
|
3055
|
+
- **Optional field handling**: `.optional()` fields are converted to `.nullable()` with a transform that converts `null` → `undefined`, preserving optional semantics while satisfying OpenAI's strict mode requirements
|
|
3056
|
+
- **Preserves nullable fields**: Intentionally `.nullable()` fields remain unchanged
|
|
3057
|
+
- **Deep transformation**: Handles `.optional()` fields at any nesting level (objects, arrays, unions, etc.)
|
|
3058
|
+
- **JSON Schema objects**: Not transformed, only Zod schemas
|
|
3059
|
+
|
|
3060
|
+
**Example**
|
|
3061
|
+
|
|
3062
|
+
```typescript
|
|
3063
|
+
const agent = new Agent({
|
|
3064
|
+
name: 'data-extractor',
|
|
3065
|
+
model: { provider: 'openai', modelId: 'gpt-4o' },
|
|
3066
|
+
instructions: 'Extract user information',
|
|
3067
|
+
});
|
|
3068
|
+
|
|
3069
|
+
const schema = z.object({
|
|
3070
|
+
name: z.string(),
|
|
3071
|
+
age: z.number().optional(),
|
|
3072
|
+
deletedAt: z.date().nullable(),
|
|
3073
|
+
});
|
|
3074
|
+
|
|
3075
|
+
// Schema is automatically transformed for OpenAI compatibility
|
|
3076
|
+
const result = await agent.generate('Extract: John, deleted yesterday', {
|
|
3077
|
+
structuredOutput: { schema },
|
|
3078
|
+
});
|
|
3079
|
+
|
|
3080
|
+
// Result: { name: 'John', age: undefined, deletedAt: null }
|
|
3081
|
+
```
|
|
3082
|
+
|
|
3083
|
+
- When a workflow step is resumed, the writer parameter was not being properly passed through, causing writer.custom() calls to fail. This fix ensures the writableStream parameter is correctly passed to both run.resume() and run.start() calls in the workflow execution engine, allowing custom events to be emitted properly during resume operations. ([#10720](https://github.com/mastra-ai/mastra/pull/10720))
|
|
3084
|
+
|
|
3085
|
+
- Added support for .streamVNext and .stream that uses it in the inngest execution engine ([#9434](https://github.com/mastra-ai/mastra/pull/9434))
|
|
3086
|
+
|
|
3087
|
+
- Fix reasoning content being lost when text-start chunk arrives before reasoning-end ([#11494](https://github.com/mastra-ai/mastra/pull/11494))
|
|
3088
|
+
|
|
3089
|
+
Some model providers (e.g., ZAI/glm-4.6) return streaming chunks where `text-start` arrives before `reasoning-end`. Previously, this would clear the accumulated reasoning deltas, resulting in empty reasoning content in the final message. Now `text-start` is properly excluded from triggering the reasoning state reset, allowing `reasoning-end` to correctly save the reasoning content.
|
|
3090
|
+
|
|
3091
|
+
- pass writableStream parameter to workflow execution ([#9139](https://github.com/mastra-ai/mastra/pull/9139))
|
|
3092
|
+
|
|
3093
|
+
- Adds native @ai-sdk/deepseek provider support instead of using the OpenAI-compatible fallback. ([#10822](https://github.com/mastra-ai/mastra/pull/10822))
|
|
3094
|
+
|
|
3095
|
+
```typescript
|
|
3096
|
+
const agent = new Agent({
|
|
3097
|
+
model: 'deepseek/deepseek-reasoner',
|
|
3098
|
+
});
|
|
3099
|
+
|
|
3100
|
+
// With provider options for reasoning
|
|
3101
|
+
const response = await agent.generate('Solve this problem', {
|
|
3102
|
+
providerOptions: {
|
|
3103
|
+
deepseek: {
|
|
3104
|
+
thinking: { type: 'enabled' },
|
|
3105
|
+
},
|
|
3106
|
+
},
|
|
3107
|
+
});
|
|
3108
|
+
```
|
|
3109
|
+
|
|
3110
|
+
Also updates the doc generation scripts so DeepSeek provider options show up in the generated docs.
|
|
3111
|
+
|
|
3112
|
+
- Fix workflow throwing error when using .map after .foreach ([#11352](https://github.com/mastra-ai/mastra/pull/11352))
|
|
3113
|
+
|
|
3114
|
+
- Previously, network execution steps were not being tracked correctly in the AI SDK stream transformation. Steps were being duplicated rather than updated, and critical metadata like step IDs, iterations, and task information was missing or incorrectly structured. ([#10432](https://github.com/mastra-ai/mastra/pull/10432))
|
|
3115
|
+
|
|
3116
|
+
**Changes:**
|
|
3117
|
+
- Enhanced step tracking in `AgentNetworkToAISDKTransformer` to properly maintain step state throughout execution lifecycle
|
|
3118
|
+
- Steps are now identified by unique IDs and updated in place rather than creating duplicates
|
|
3119
|
+
- Added proper iteration and task metadata to each step in the network execution flow
|
|
3120
|
+
- Fixed agent, workflow, and tool execution events to correctly populate step data
|
|
3121
|
+
- Updated network stream event types to include `networkId`, `workflowId`, and consistent `runId` tracking
|
|
3122
|
+
- Added test coverage for network custom data chunks with comprehensive validation
|
|
3123
|
+
|
|
3124
|
+
This ensures the AI SDK correctly represents the full execution flow of agent networks with accurate step sequencing and metadata.
|
|
3125
|
+
|
|
3126
|
+
- Add `resumeGenerate` method for resuming agent via generate ([#11503](https://github.com/mastra-ai/mastra/pull/11503))
|
|
3127
|
+
Add `runId` and `suspendPayload` to fullOutput of agent stream
|
|
3128
|
+
Default `suspendedToolRunId` to empty string to prevent `null` issue
|
|
3129
|
+
|
|
3130
|
+
- Remove tools passed to the Routing Agent in .network() ([#9374](https://github.com/mastra-ai/mastra/pull/9374))
|
|
3131
|
+
|
|
3132
|
+
- Fix corrupted provider-registry.json file in global cache and regenerate corrupted files ([#10606](https://github.com/mastra-ai/mastra/pull/10606))
|
|
3133
|
+
|
|
3134
|
+
- The iteration counter in agent networks was stuck at 0 due to a faulty ternary operator that treated 0 as falsy. This prevented `maxSteps` from working correctly, causing infinite loops when the routing agent kept selecting primitives instead of returning "none". ([#9762](https://github.com/mastra-ai/mastra/pull/9762))
|
|
3135
|
+
|
|
3136
|
+
**Changes:**
|
|
3137
|
+
- Fixed iteration counter logic in `loop/network/index.ts` from `(inputData.iteration ? inputData.iteration : -1) + 1` to `(inputData.iteration ?? -1) + 1`
|
|
3138
|
+
- Changed initial iteration value from `0` to `-1` so first iteration correctly starts at 0
|
|
3139
|
+
- Added `checkIterations()` helper to validate iteration counting in all network tests
|
|
3140
|
+
|
|
3141
|
+
Fixes #9314
|
|
3142
|
+
|
|
3143
|
+
- Fixed CachedToken tracking in all Observability Exporters. Also fixed TimeToFirstToken in Langfuse, Braintrust, PostHog exporters. Fixed trace formatting in Posthog Exporter. ([#11029](https://github.com/mastra-ai/mastra/pull/11029))
|
|
3144
|
+
|
|
3145
|
+
- Fix generating provider-registry.json ([#10392](https://github.com/mastra-ai/mastra/pull/10392))
|
|
3146
|
+
|
|
3147
|
+
- Fix types from ai v4 ([#9818](https://github.com/mastra-ai/mastra/pull/9818))
|
|
3148
|
+
|
|
3149
|
+
- Add restart method to workflow run that allows restarting an active workflow run ([#9750](https://github.com/mastra-ai/mastra/pull/9750))
|
|
3150
|
+
Add status filter to `listWorkflowRuns`
|
|
3151
|
+
Add automatic restart to restart active workflow runs when server starts
|
|
3152
|
+
|
|
3153
|
+
- Save correct status in snapshot for all workflow parallel steps. ([#9379](https://github.com/mastra-ai/mastra/pull/9379))
|
|
3154
|
+
This ensures when you poll workflow run result using `getWorkflowRunExecutionResult(runId)`, you get the right status for all parallel steps
|
|
3155
|
+
|
|
3156
|
+
- Prevent changing workflow status to suspended when some parallel steps are still running ([#9431](https://github.com/mastra-ai/mastra/pull/9431))
|
|
3157
|
+
|
|
3158
|
+
- Add ability to pass agent options when wrapping an agent with createStep. This allows configuring agent execution settings when using agents as workflow steps. ([#9199](https://github.com/mastra-ai/mastra/pull/9199))
|
|
3159
|
+
|
|
3160
|
+
- Validate schemas by default in workflow. Previously, if you want schemas in the workflow to be validated, you'd have to add `validateInputs` option, now, this will be done by default but can be disabled. ([#10186](https://github.com/mastra-ai/mastra/pull/10186))
|
|
3161
|
+
|
|
3162
|
+
For workflows whose schemas and step schemas you don't want validated, do this
|
|
3163
|
+
|
|
3164
|
+
```diff
|
|
3165
|
+
createWorkflow({
|
|
3166
|
+
+ options: {
|
|
3167
|
+
+ validateInputs: false
|
|
3168
|
+
+ }
|
|
3169
|
+
})
|
|
3170
|
+
```
|
|
3171
|
+
|
|
3172
|
+
- Fix TypeScript error when using Zod schemas in `defaultOptions.structuredOutput` ([#10710](https://github.com/mastra-ai/mastra/pull/10710))
|
|
3173
|
+
|
|
3174
|
+
Previously, defining `structuredOutput.schema` in `defaultOptions` would cause a TypeScript error because the type only accepted `undefined`. Now any valid `OutputSchema` is correctly accepted.
|
|
3175
|
+
|
|
3176
|
+
- Return state too if `includeState: true` is in `outputOptions` and workflow run is not successful ([#10806](https://github.com/mastra-ai/mastra/pull/10806))
|
|
3177
|
+
|
|
3178
|
+
- Fix MCP server registration ([#9802](https://github.com/mastra-ai/mastra/pull/9802))
|
|
3179
|
+
|
|
3180
|
+
- Fix network loop iteration counter and usage promise handling: ([#9408](https://github.com/mastra-ai/mastra/pull/9408))
|
|
3181
|
+
- Fixed iteration counter in network loop that was stuck at 0 due to falsy check. Properly handled zero values to ensure maxSteps is correctly enforced.
|
|
3182
|
+
- Fixed usage promise resolution in RunOutput stream by properly resolving or rejecting the promise on stream close, preventing hanging promises when streams complete.
|
|
3183
|
+
|
|
3184
|
+
- Fixed migration CLI failing with MIGRATION_REQUIRED error during Mastra import. Added MASTRA_DISABLE_STORAGE_INIT environment variable to skip auto-initialization of storage, allowing the migration command to import user's Mastra config without triggering the migration check. Also improved the migration prompt display to show warning messages before the confirmation dialog. ([#12100](https://github.com/mastra-ai/mastra/pull/12100))
|
|
3185
|
+
|
|
3186
|
+
- What changed: ([#10998](https://github.com/mastra-ai/mastra/pull/10998))
|
|
3187
|
+
|
|
3188
|
+
Support for sequential tool execution was added. Tool call concurrency is now set conditionally, defaulting to 1 when sequential execution is needed (to avoid race conditions that interfere with human-in-the-loop approval during the workflow) rather than the default of 10 when concurrency is acceptable.
|
|
3189
|
+
|
|
3190
|
+
How it was changed:
|
|
3191
|
+
|
|
3192
|
+
A `sequentialExecutionRequired` constant was set to a boolean depending on whether any of the tools involved in a returned agentic execution workflow would require approval. If any tool has a 'suspendSchema' property (used for conditionally suspending execution and waiting for human input), or if they have their `requireApproval` property set to `true`, then the concurrency property used in the toolCallStep is set to 1, causing sequential execution. The old default of 10 remains otherwise.
|
|
3193
|
+
|
|
3194
|
+
- Fix generateTitle for pre-created threads ([#11771](https://github.com/mastra-ai/mastra/pull/11771))
|
|
3195
|
+
- Title generation now works automatically for pre-created threads (via client SDK)
|
|
3196
|
+
- When `generateTitle: true` is configured, titles are generated on the first user message
|
|
3197
|
+
- Detection is based on message history: if no existing user messages in memory, it's the first message
|
|
3198
|
+
- No metadata flags required - works seamlessly with optimistic UI patterns
|
|
3199
|
+
|
|
3200
|
+
Fixes #11757
|
|
3201
|
+
|
|
3202
|
+
- Fix inngest parallel workflow ([#10169](https://github.com/mastra-ai/mastra/pull/10169))
|
|
3203
|
+
Fix tool as step in inngest
|
|
3204
|
+
Fix inngest nested workflow
|
|
3205
|
+
|
|
3206
|
+
- Adds thread cloning to create independent copies of conversations that can diverge. ([#11517](https://github.com/mastra-ai/mastra/pull/11517))
|
|
3207
|
+
|
|
3208
|
+
```typescript
|
|
3209
|
+
// Clone a thread
|
|
3210
|
+
const { thread, clonedMessages } = await memory.cloneThread({
|
|
3211
|
+
sourceThreadId: 'thread-123',
|
|
3212
|
+
title: 'My Clone',
|
|
3213
|
+
options: {
|
|
3214
|
+
messageLimit: 10, // optional: only copy last N messages
|
|
3215
|
+
},
|
|
3216
|
+
});
|
|
3217
|
+
|
|
3218
|
+
// Check if a thread is a clone
|
|
3219
|
+
if (memory.isClone(thread)) {
|
|
3220
|
+
const source = await memory.getSourceThread(thread.id);
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
// List all clones of a thread
|
|
3224
|
+
const clones = await memory.listClones('thread-123');
|
|
3225
|
+
```
|
|
3226
|
+
|
|
3227
|
+
Includes:
|
|
3228
|
+
- Storage implementations for InMemory, PostgreSQL, LibSQL, Upstash
|
|
3229
|
+
- API endpoint: `POST /api/memory/threads/:threadId/clone`
|
|
3230
|
+
- Embeddings created for cloned messages (semantic recall)
|
|
3231
|
+
- Clone button in playground UI Memory tab
|
|
3232
|
+
|
|
3233
|
+
- Exports `convertFullStreamChunkToMastra` from the stream module for AI SDK stream chunk transformations. ([#10911](https://github.com/mastra-ai/mastra/pull/10911))
|
|
3234
|
+
|
|
3235
|
+
- Add support for `providerOptions` when defining tools. This allows developers to specify provider-specific configurations (like Anthropic's `cacheControl`) per tool. ([#10649](https://github.com/mastra-ai/mastra/pull/10649))
|
|
3236
|
+
|
|
3237
|
+
```typescript
|
|
3238
|
+
createTool({
|
|
3239
|
+
id: 'my-tool',
|
|
3240
|
+
providerOptions: {
|
|
3241
|
+
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
3242
|
+
},
|
|
3243
|
+
// ...
|
|
3244
|
+
});
|
|
3245
|
+
```
|
|
3246
|
+
|
|
3247
|
+
- Remove `waitForEvent` from workflows. `waitForEvent` is now removed, please use suspend & resume flow instead. See https://mastra.ai/en/docs/workflows/suspend-and-resume for more details on suspend & resume flow. ([#9214](https://github.com/mastra-ai/mastra/pull/9214))
|
|
3248
|
+
|
|
3249
|
+
- Fix delayed promises rejecting when stream suspends on tool-call-approval ([#11278](https://github.com/mastra-ai/mastra/pull/11278))
|
|
3250
|
+
|
|
3251
|
+
When a stream ends in suspended state (e.g., requiring tool approval), the delayed promises like `toolResults`, `toolCalls`, `text`, etc. now resolve with partial results instead of rejecting with an error. This allows consumers to access data that was produced before the suspension.
|
|
3252
|
+
|
|
3253
|
+
Also improves generic type inference for `LLMStepResult` and related types throughout the streaming infrastructure.
|
|
3254
|
+
|
|
3255
|
+
- Workflow validation zod v4 support ([#9319](https://github.com/mastra-ai/mastra/pull/9319))
|
|
3256
|
+
|
|
3257
|
+
- Fixed semantic recall fetching all thread messages instead of only matched ones. ([#11435](https://github.com/mastra-ai/mastra/pull/11435))
|
|
3258
|
+
|
|
3259
|
+
When using `semanticRecall` with `scope: 'thread'`, the processor was incorrectly fetching all messages from the thread instead of just the semantically matched messages with their context. This caused memory to return far more messages than expected when `topK` and `messageRange` were set to small values.
|
|
3260
|
+
|
|
3261
|
+
Fixes #11428
|
|
3262
|
+
|
|
3263
|
+
- Improved test description in ModelsDevGateway to clearly reflect the behavior being tested ([#11460](https://github.com/mastra-ai/mastra/pull/11460))
|
|
3264
|
+
|
|
3265
|
+
- Add optional `partial` query parameter to `/api/agents` and `/api/workflows` endpoints to return minimal data without schemas, reducing payload size for list views: ([#10886](https://github.com/mastra-ai/mastra/pull/10886))
|
|
3266
|
+
- When `partial=true`: tool schemas (inputSchema, outputSchema) are omitted
|
|
3267
|
+
- When `partial=true`: workflow steps are replaced with stepCount integer
|
|
3268
|
+
- When `partial=true`: workflow root schemas (inputSchema, outputSchema) are omitted
|
|
3269
|
+
- Maintains backward compatibility when partial parameter is not provided
|
|
3270
|
+
|
|
3271
|
+
**Server Endpoint Usage**
|
|
3272
|
+
|
|
3273
|
+
```bash
|
|
3274
|
+
# Get partial agent data (no tool schemas)
|
|
3275
|
+
GET /api/agents?partial=true
|
|
3276
|
+
|
|
3277
|
+
# Get full agent data (default behavior)
|
|
3278
|
+
GET /api/agents
|
|
3279
|
+
|
|
3280
|
+
# Get partial workflow data (stepCount instead of steps, no schemas)
|
|
3281
|
+
GET /api/workflows?partial=true
|
|
3282
|
+
|
|
3283
|
+
# Get full workflow data (default behavior)
|
|
3284
|
+
GET /api/workflows
|
|
3285
|
+
```
|
|
3286
|
+
|
|
3287
|
+
**Client SDK Usage**
|
|
3288
|
+
|
|
3289
|
+
```typescript
|
|
3290
|
+
import { MastraClient } from '@mastra/client-js';
|
|
3291
|
+
|
|
3292
|
+
const client = new MastraClient({ baseUrl: 'http://localhost:4111' });
|
|
3293
|
+
|
|
3294
|
+
// Get partial agent list (smaller payload)
|
|
3295
|
+
const partialAgents = await client.listAgents({ partial: true });
|
|
3296
|
+
|
|
3297
|
+
// Get full agent list with tool schemas
|
|
3298
|
+
const fullAgents = await client.listAgents();
|
|
3299
|
+
|
|
3300
|
+
// Get partial workflow list (smaller payload)
|
|
3301
|
+
const partialWorkflows = await client.listWorkflows({ partial: true });
|
|
3302
|
+
|
|
3303
|
+
// Get full workflow list with steps and schemas
|
|
3304
|
+
const fullWorkflows = await client.listWorkflows();
|
|
3305
|
+
```
|
|
3306
|
+
|
|
3307
|
+
- Use memory mock in server tests ([#9486](https://github.com/mastra-ai/mastra/pull/9486))
|
|
3308
|
+
|
|
3309
|
+
- Add human-in-the-loop support for workflows used in agent ([#10871](https://github.com/mastra-ai/mastra/pull/10871))
|
|
3310
|
+
|
|
3311
|
+
- Real-time span export for Inngest workflow engine ([#11973](https://github.com/mastra-ai/mastra/pull/11973))
|
|
3312
|
+
- Spans are now exported immediately when created and ended, instead of being batched at workflow completion
|
|
3313
|
+
- Added durable span lifecycle hooks (`createStepSpan`, `endStepSpan`, `errorStepSpan`, `createChildSpan`, `endChildSpan`, `errorChildSpan`) that wrap span operations in Inngest's `step.run()` for memoization
|
|
3314
|
+
- Added `rebuildSpan()` method to reconstruct span objects from exported data after Inngest replay
|
|
3315
|
+
- Fixed nested workflow step spans missing output data
|
|
3316
|
+
- Spans correctly maintain parent-child relationships across Inngest's durable execution boundaries using `tracingIds`
|
|
3317
|
+
|
|
3318
|
+
- Fix network routing agent smoothstreaming ([#9247](https://github.com/mastra-ai/mastra/pull/9247))
|
|
3319
|
+
|
|
3320
|
+
- Adds type inference for `mastra.get*ById` functions. Only those registered at the top level mastra instance will get inferred. MCP and tool id's do not get inferred yet, those need additional changes. ([#10199](https://github.com/mastra-ai/mastra/pull/10199))
|
|
3321
|
+
|
|
3322
|
+
- Cache processor instances in MastraMemory to preserve embedding cache across calls ([#11720](https://github.com/mastra-ai/mastra/pull/11720))
|
|
3323
|
+
Fixed issue where getInputProcessors() and getOutputProcessors() created new processor instances on each call, causing the SemanticRecall embedding cache to be discarded. Processor instances (SemanticRecall, WorkingMemory, MessageHistory) are now cached and reused, reducing unnecessary embedding API calls and improving latency.
|
|
3324
|
+
Also added cache invalidation when setStorage(), setVector(), or setEmbedder() are called to ensure processors use updated dependencies.
|
|
3325
|
+
Fixes #11455
|
|
3326
|
+
|
|
3327
|
+
- Bump @ai-sdk/openai from 3.0.0-beta.102 to 3.0.1 ([#11377](https://github.com/mastra-ai/mastra/pull/11377))
|
|
3328
|
+
|
|
3329
|
+
- Add timeTravel to workflows. This makes it possible to start a workflow run from a particular step in the workflow ([#9994](https://github.com/mastra-ai/mastra/pull/9994))
|
|
3330
|
+
|
|
3331
|
+
Example code:
|
|
3332
|
+
|
|
3333
|
+
```ts
|
|
3334
|
+
const result = await run.timeTravel({
|
|
3335
|
+
step: 'step2',
|
|
3336
|
+
inputData: {
|
|
3337
|
+
value: 'input',
|
|
3338
|
+
},
|
|
3339
|
+
});
|
|
3340
|
+
```
|
|
3341
|
+
|
|
3342
|
+
- Fixed duplicate assistant messages appearing when using `useChat` with memory enabled. ([#11195](https://github.com/mastra-ai/mastra/pull/11195))
|
|
3343
|
+
|
|
3344
|
+
**What was happening:** When using `useChat` with `chatRoute` and memory, assistant messages were being duplicated in storage after multiple conversation turns. This occurred because the backend-generated message ID wasn't being sent back to `useChat`, causing ID mismatches during deduplication.
|
|
3345
|
+
|
|
3346
|
+
**What changed:**
|
|
3347
|
+
- The backend now sends the assistant message ID in the stream's start event, so `useChat` uses the same ID as storage
|
|
3348
|
+
- Custom `data-*` parts (from `writer.custom()`) are now preserved when messages contain V5 tool parts
|
|
3349
|
+
|
|
3350
|
+
Fixes #11091
|
|
3351
|
+
|
|
3352
|
+
- Fixed sub-agents in `agent.network()` not receiving conversation history. ([#11825](https://github.com/mastra-ai/mastra/pull/11825))
|
|
3353
|
+
|
|
3354
|
+
Sub-agents now have access to previous user messages from the conversation, enabling them to understand context from earlier exchanges. This resolves the issue where sub-agents would respond without knowledge of prior conversation turns.
|
|
3355
|
+
|
|
3356
|
+
Fixes #11468
|
|
3357
|
+
|
|
3358
|
+
- Remove format from stream/generate ([#9577](https://github.com/mastra-ai/mastra/pull/9577))
|
|
3359
|
+
|
|
3360
|
+
- - Add persistence for custom data chunks (`data-*` parts) emitted via `writer.custom()` in tools ([#10884](https://github.com/mastra-ai/mastra/pull/10884))
|
|
3361
|
+
- Data chunks are now saved to message storage so they survive page refreshes
|
|
3362
|
+
- Update `@assistant-ui/react` to v0.11.47 with native `DataMessagePart` support
|
|
3363
|
+
- Convert `data-*` parts to `DataMessagePart` format (`{ type: 'data', name: string, data: T }`)
|
|
3364
|
+
- Update related `@assistant-ui/*` packages for compatibility
|
|
3365
|
+
|
|
3366
|
+
- Fix processInputStep so it runs correctly. ([#10909](https://github.com/mastra-ai/mastra/pull/10909))
|
|
3367
|
+
|
|
3368
|
+
- Fix agent network working memory tool routing. Memory tools are now included in routing agent instructions but excluded from its direct tool calls, allowing the routing agent to properly route to tool execution steps for memory updates. ([#9428](https://github.com/mastra-ai/mastra/pull/9428))
|
|
3369
|
+
|
|
3370
|
+
- Fix working memory zod to json schema conversion to use schema-compat zodtoJsonSchema fn. ([#10391](https://github.com/mastra-ai/mastra/pull/10391))
|
|
3371
|
+
|
|
3372
|
+
- Fix TypeScript type narrowing when iterating over typed RequestContext ([#10850](https://github.com/mastra-ai/mastra/pull/10850))
|
|
3373
|
+
|
|
3374
|
+
The `set()` and `get()` methods on a typed `RequestContext` already provide full type safety. However, when iterating with `entries()`, `keys()`, `values()`, or `forEach()`, TypeScript couldn't narrow the value type based on key checks.
|
|
3375
|
+
|
|
3376
|
+
Now it can:
|
|
3377
|
+
|
|
3378
|
+
```typescript
|
|
3379
|
+
const ctx = new RequestContext<{ userId: string; maxTokens: number }>();
|
|
3380
|
+
|
|
3381
|
+
// Direct access:
|
|
3382
|
+
const tokens = ctx.get('maxTokens'); // number
|
|
3383
|
+
|
|
3384
|
+
// Iteration now works too:
|
|
3385
|
+
for (const [key, value] of ctx.entries()) {
|
|
3386
|
+
if (key === 'maxTokens') {
|
|
3387
|
+
value.toFixed(0); // TypeScript knows value is number
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
```
|
|
3391
|
+
|
|
3392
|
+
- Fixes parallel tool call issue with Gemini 3 Pro by preventing step-start parts from being inserted between consecutive tool parts in the `addStartStepPartsForAIV5` function. This ensures that the AI SDK's `convertToModelMessages` correctly preserves the order of parallel tool calls and maintains the `thought_signature` on the first tool call as required by Gemini's API. ([#10372](https://github.com/mastra-ai/mastra/pull/10372))
|
|
3393
|
+
|
|
3394
|
+
- Fixes assets not being downloaded when available ([#10079](https://github.com/mastra-ai/mastra/pull/10079))
|
|
3395
|
+
|
|
3396
|
+
- Fixed OpenAI reasoning message merging so distinct reasoning items are no longer dropped when they share a message ID. Prevents downstream errors where a function call is missing its required "reasoning" item. See #9005. ([#10614](https://github.com/mastra-ai/mastra/pull/10614))
|
|
3397
|
+
|
|
3398
|
+
- Fix creating system messages from inside processors using processInput. ([#9469](https://github.com/mastra-ai/mastra/pull/9469))
|
|
3399
|
+
|
|
3400
|
+
- Fix usage tracking with agent network ([#9226](https://github.com/mastra-ai/mastra/pull/9226))
|
|
3401
|
+
|
|
3402
|
+
- Remove unused dependencies ([#10019](https://github.com/mastra-ai/mastra/pull/10019))
|
|
3403
|
+
|
|
3404
|
+
- fix(workflows): ensure writer.custom() bubbles up from nested workflows and loops ([#11422](https://github.com/mastra-ai/mastra/pull/11422))
|
|
3405
|
+
|
|
3406
|
+
Previously, when using `writer.custom()` in steps within nested sub-workflows or loops (like `dountil`), the custom data events would not properly bubble up to the top-level workflow stream. This fix ensures that custom events are now correctly propagated through the nested workflow hierarchy without modification, allowing them to be consumed at the top level.
|
|
3407
|
+
|
|
3408
|
+
This brings workflows in line with the existing behavior for agents, where custom data chunks properly bubble up through sub-agent execution.
|
|
3409
|
+
|
|
3410
|
+
**What changed:**
|
|
3411
|
+
- Modified the `nestedWatchCb` function in workflow event handling to detect and preserve `data-*` custom events
|
|
3412
|
+
- Custom events now bubble up directly without being wrapped or modified
|
|
3413
|
+
- Regular workflow events continue to work as before with proper step ID prefixing
|
|
3414
|
+
|
|
3415
|
+
**Example:**
|
|
3416
|
+
|
|
3417
|
+
```typescript
|
|
3418
|
+
const subStep = createStep({
|
|
3419
|
+
id: 'subStep',
|
|
3420
|
+
execute: async ({ writer }) => {
|
|
3421
|
+
await writer.custom({
|
|
3422
|
+
type: 'custom-progress',
|
|
3423
|
+
data: { status: 'processing' },
|
|
3424
|
+
});
|
|
3425
|
+
return { result: 'done' };
|
|
3426
|
+
},
|
|
3427
|
+
});
|
|
3428
|
+
|
|
3429
|
+
const subWorkflow = createWorkflow({ id: 'sub' }).then(subStep).commit();
|
|
3430
|
+
|
|
3431
|
+
const topWorkflow = createWorkflow({ id: 'top' }).then(subWorkflow).commit();
|
|
3432
|
+
|
|
3433
|
+
const run = await topWorkflow.createRun();
|
|
3434
|
+
const stream = run.stream({ inputData: {} });
|
|
3435
|
+
|
|
3436
|
+
// Custom events from subStep now properly appear in the top-level stream
|
|
3437
|
+
for await (const event of stream) {
|
|
3438
|
+
if (event.type === 'custom-progress') {
|
|
3439
|
+
console.log(event.data); // { status: 'processing' }
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
```
|
|
3443
|
+
|
|
3444
|
+
- Fix message conversion for incomplete client-side tool calls ([#9749](https://github.com/mastra-ai/mastra/pull/9749))
|
|
3445
|
+
|
|
3446
|
+
Fixed handling of `input-available` tool state in `sanitizeV5UIMessages()` to differentiate between two use cases:
|
|
3447
|
+
1. **Response messages FROM the LLM**: Keep `input-available` states (tool calls waiting for client-side execution) in `response.messages` for proper message history.
|
|
3448
|
+
2. **Prompt messages TO the LLM**: Filter out `input-available` states when sending historical messages back to the LLM, as these incomplete tool calls (without results) cause errors in the OpenAI Responses API.
|
|
3449
|
+
|
|
3450
|
+
The fix adds a `filterIncompleteToolCalls` parameter to control this behavior based on whether messages are being sent to or received from the LLM.
|
|
3451
|
+
|
|
3452
|
+
- Fix `runEvals()` to automatically save scores to storage, making them visible in Studio observability. ([#11516](https://github.com/mastra-ai/mastra/pull/11516))
|
|
3453
|
+
|
|
3454
|
+
Previously, `runEvals()` would calculate scores but not persist them to storage, requiring users to manually implement score saving via the `onItemComplete` callback. Scores now automatically save when the target (Agent/Workflow) has an associated Mastra instance with storage configured.
|
|
3455
|
+
|
|
3456
|
+
**What changed:**
|
|
3457
|
+
- Scores are now automatically saved to storage after each evaluation run
|
|
3458
|
+
- Fixed compatibility with both Agent (`getMastraInstance()`) and Workflow (`.mastra` getter)
|
|
3459
|
+
- Saved scores include complete context: `groundTruth` (in `additionalContext`), `requestContext`, `traceId`, and `spanId`
|
|
3460
|
+
- Scores are marked with `source: 'TEST'` to distinguish them from live scoring
|
|
3461
|
+
|
|
3462
|
+
**Migration:**
|
|
3463
|
+
No action required. The `onItemComplete` workaround for saving scores can be removed if desired, but will continue to work for custom logic.
|
|
3464
|
+
|
|
3465
|
+
**Example:**
|
|
3466
|
+
|
|
3467
|
+
```typescript
|
|
3468
|
+
const result = await runEvals({
|
|
3469
|
+
target: mastra.getWorkflow("myWorkflow"),
|
|
3470
|
+
data: [{ input: {...}, groundTruth: {...} }],
|
|
3471
|
+
scorers: [myScorer],
|
|
3472
|
+
});
|
|
3473
|
+
// Scores are now automatically saved and visible in Studio!
|
|
3474
|
+
```
|
|
3475
|
+
|
|
3476
|
+
- Make suspendPayload optional when calling `suspend()` ([#9926](https://github.com/mastra-ai/mastra/pull/9926))
|
|
3477
|
+
Save value returned as `suspendOutput` if user returns data still after calling `suspend()`
|
|
3478
|
+
Automatically call `commit()` on uncommitted workflows when registering in Mastra instance
|
|
3479
|
+
Show actual suspendPayload on Studio in suspend/resume flow
|
|
3480
|
+
|
|
3481
|
+
- Add `initialState` and `outputOptions` to run.stream() call. ([#9238](https://github.com/mastra-ai/mastra/pull/9238))
|
|
3482
|
+
|
|
3483
|
+
Example code
|
|
3484
|
+
|
|
3485
|
+
```ts
|
|
3486
|
+
const run = await workflow.createRunAsync();
|
|
3487
|
+
|
|
3488
|
+
const streamResult = run.stream({
|
|
3489
|
+
inputData: {},
|
|
3490
|
+
initialState: { value: 'test-state', otherValue: 'test-other-state' },
|
|
3491
|
+
outputOptions: { includeState: true },
|
|
3492
|
+
});
|
|
3493
|
+
```
|
|
3494
|
+
|
|
3495
|
+
Then the result from the stream will include the final state information
|
|
3496
|
+
|
|
3497
|
+
```ts
|
|
3498
|
+
const executionResult = await streamResult.result;
|
|
3499
|
+
console.log(executionResult.state);
|
|
3500
|
+
```
|
|
3501
|
+
|
|
3502
|
+
- Fixed double validation bug that prevented Zod transforms from working correctly in tool schemas. ([#11025](https://github.com/mastra-ai/mastra/pull/11025))
|
|
3503
|
+
|
|
3504
|
+
When tools with Zod `.transform()` or `.pipe()` in their `outputSchema` were executed through the Agent pipeline, validation was happening twice - once in Tool.execute() (correct) and again in CoreToolBuilder (incorrect). The second validation received already-transformed data but expected pre-transform data, causing validation errors.
|
|
3505
|
+
|
|
3506
|
+
This fix enables proper use of Zod transforms in both `inputSchema` (for normalizing/cleaning input data) and `outputSchema` (for transforming output data to be LLM-friendly).
|
|
3507
|
+
|
|
3508
|
+
- Add visual styles and labels for more workflow node types ([#9777](https://github.com/mastra-ai/mastra/pull/9777))
|
|
3509
|
+
|
|
3510
|
+
- Fix autoresume not working fine in useChat ([#11486](https://github.com/mastra-ai/mastra/pull/11486))
|
|
3511
|
+
|
|
3512
|
+
- Multiple Processor improvements including: ([#10947](https://github.com/mastra-ai/mastra/pull/10947))
|
|
3513
|
+
- Workflows can now return tripwires, they bubble up from agents that return tripwires in a step
|
|
3514
|
+
- You can write processors as workflows using the existing Workflow primitive, every processor flow is now a workflow.
|
|
3515
|
+
- tripwires that you throw can now return additional information including ability to retry the step
|
|
3516
|
+
- New processor method `processOutputStep` added which runs after every step.
|
|
3517
|
+
|
|
3518
|
+
**What's new:**
|
|
3519
|
+
|
|
3520
|
+
**1. Retry mechanism with LLM feedback** - Processors can now request retries with feedback that gets sent back to the LLM:
|
|
3521
|
+
|
|
3522
|
+
```typescript
|
|
3523
|
+
processOutputStep: async ({ text, abort, retryCount }) => {
|
|
3524
|
+
if (isLowQuality(text)) {
|
|
3525
|
+
abort('Response quality too low', { retry: true, metadata: { score: 0.6 } });
|
|
3526
|
+
}
|
|
3527
|
+
return [];
|
|
3528
|
+
};
|
|
3529
|
+
```
|
|
3530
|
+
|
|
3531
|
+
Configure with `maxProcessorRetries` (default: 3). Rejected steps are preserved in `result.steps[n].tripwire`. Retries are only available in `processOutputStep` and `processInputStep`. It will replay the step with additional context added.
|
|
3532
|
+
|
|
3533
|
+
**2. Workflow orchestration for processors** - Processors can now be composed using workflow primitives:
|
|
3534
|
+
|
|
3535
|
+
```typescript
|
|
3536
|
+
import { createStep, createWorkflow } from '@mastra/core/workflows';
|
|
3537
|
+
import {
|
|
3538
|
+
ProcessorStepSchema,
|
|
3539
|
+
} from '@mastra/core/processors';
|
|
3540
|
+
|
|
3541
|
+
const moderationWorkflow = createWorkflow({ id: 'moderation', inputSchema: ProcessorStepSchema, outputSchema: ProcessorStepSchema })
|
|
3542
|
+
.then(createStep(new lengthValidator({...})))
|
|
3543
|
+
.parallel([createStep(new piiDetector({...}), createStep(new toxicityChecker({...}))])
|
|
3544
|
+
.commit();
|
|
3545
|
+
|
|
3546
|
+
const agent = new Agent({ inputProcessors: [moderationWorkflow] });
|
|
3547
|
+
```
|
|
3548
|
+
|
|
3549
|
+
Every processor array that gets passed to an agent gets added as a workflow
|
|
3550
|
+
<img width="614" height="673" alt="image" src="https://github.com/user-attachments/assets/0d79f1fd-8fca-4d86-8b45-22fddea984a8" />
|
|
3551
|
+
|
|
3552
|
+
**3. Extended tripwire API** - `abort()` now accepts options for retry control and typed metadata:
|
|
3553
|
+
|
|
3554
|
+
```typescript
|
|
3555
|
+
abort('reason', { retry: true, metadata: { score: 0.8, category: 'quality' } });
|
|
3556
|
+
```
|
|
3557
|
+
|
|
3558
|
+
**4. New `processOutputStep` method** - Per-step output processing with access to step number, finish reason, tool calls, and retry count.
|
|
3559
|
+
|
|
3560
|
+
**5. Workflow tripwire status** - Workflows now have a `'tripwire'` status distinct from `'failed'`, properly bubbling up processor rejections.
|
|
3561
|
+
|
|
3562
|
+
- Updated dependencies [[`b9b7ffd`](https://github.com/mastra-ai/mastra/commit/b9b7ffdad6936a7d50b6b814b5bbe54e19087f66), [`9650cce`](https://github.com/mastra-ai/mastra/commit/9650cce52a1d917ff9114653398e2a0f5c3ba808), [`6833c69`](https://github.com/mastra-ai/mastra/commit/6833c69607418d257750bbcdd84638993d343539), [`dd1c38d`](https://github.com/mastra-ai/mastra/commit/dd1c38d1b75f1b695c27b40d8d9d6ed00d5e0f6f), [`f93e2f5`](https://github.com/mastra-ai/mastra/commit/f93e2f575e775e627e5c1927cefdd72db07858ed), [`d07b568`](https://github.com/mastra-ai/mastra/commit/d07b5687819ea8cb1dffa776d0c1765faf4aa1ae), [`51acef9`](https://github.com/mastra-ai/mastra/commit/51acef95b5977826594fe3ee24475842bd3d5780), [`af56599`](https://github.com/mastra-ai/mastra/commit/af56599d73244ae3bf0d7bcade656410f8ded37b), [`70b300e`](https://github.com/mastra-ai/mastra/commit/70b300ebc631dfc0aa14e61547fef7994adb4ea6), [`f03ae60`](https://github.com/mastra-ai/mastra/commit/f03ae60500fe350c9d828621006cdafe1975fdd8), [`3bf08bf`](https://github.com/mastra-ai/mastra/commit/3bf08bf9c7c73818ac937b5a69d90e205653115f), [`bae33d9`](https://github.com/mastra-ai/mastra/commit/bae33d91a63fbb64d1e80519e1fc1acaed1e9013), [`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc)]:
|
|
3563
|
+
- @mastra/schema-compat@1.0.0
|
|
3564
|
+
|
|
3565
|
+
## 1.0.0-beta.27
|
|
3566
|
+
|
|
3567
|
+
### Patch Changes
|
|
3568
|
+
|
|
3569
|
+
- Fixed migration CLI failing with MIGRATION_REQUIRED error during Mastra import. Added MASTRA_DISABLE_STORAGE_INIT environment variable to skip auto-initialization of storage, allowing the migration command to import user's Mastra config without triggering the migration check. Also improved the migration prompt display to show warning messages before the confirmation dialog. ([#12100](https://github.com/mastra-ai/mastra/pull/12100))
|
|
498
3570
|
|
|
499
|
-
// Dynamic discovery mode
|
|
500
|
-
export const mastra = new Mastra({
|
|
501
3571
|
|
|
502
|
-
...
|
|
3572
|
+
... 8630 more lines hidden. See full changelog in package directory.
|