Highlights
Workflows
Workflows now support global state, you can now read state
in each of your defined steps and set it withsetState
. This makes it easier to manage state over multiple steps nstead of passing it through input/output variables.
const firstStep = createStep({
id: "first-step",
execute({ setState }) {
setState({
myValue: "a value",
});
},
});
const secondStep = createStep({
id: "second-step",
execute({ state }) {
console.log(state.myValue);
},
});
createWorkflow({
id: "my-worfklow",
stateSchema: z.object({
myValue: z.string(),
}),
}).then(myStep);
Memory
Working memory can be stored using thread metadata. It allows you to set the initial wokring memory directly.
const thread = await memory.createThread({
threadId: "thread-123",
resourceId: "user-456",
title: "Medical Consultation",
metadata: {
workingMemory: `# Patient Profile
- Name: John Doe
- Blood Type: O+
- Allergies: Penicillin
- Current Medications: None
- Medical History: Hypertension (controlled)`,
},
});
UI (ai-sdk compatability)
Improved useChat
support from ai-sdk
if you're using agents in your tools. You get a custom UI message called data-tool-agent
with all relevant information.
// in src/mastra.ts
export const mastra = new Mastra({
server: {
apiRoutes: [
chatRoute({
path: "/chat",
agent: "my-agent",
}),
],
},
});
// in my useChat file
const { error, status, sendMessage, messages, regenerate, stop } =
useChat<MyMessage>({
transport: new DefaultChatTransport({
api: 'http://localhost:4111/chat',
body: {
}
}),
});
return (
<div className="flex flex-col pt-24 mx-auto w-full max-w-4xl h-screen">
<div className="flex flex-row mx-auto w-full overflow-y-auto gap-4">
<div className="flex-1">
{messages.map(message => {
return (
<div key={message.id} className="whitespace-pre-wrap">
{message.role === 'user' ? 'User: ' : 'AI: '}{' '}
{message.parts
.filter(part => part.type === 'data-tool-agent')
.map((part) => {
return <CustomWidget key={part.id} {...part.data} />
})}
{message.parts
.filter(part => part.type === 'text')
.map((part, index) => {
if (part.type === 'text') {
return <div key={index}>{part.text}</div>;
}
})
}
)
}}
</div>
</div>
</div>
)
Changelog
@mastra/agent-builder
-
Fix TypeScript errors with provider-defined tools by updating ai-v5 and openai-v5 to matching provider-utils versions. This ensures npm deduplicates to a single provider-utils instance, resolving type incompatibility issues when passing provider tools to Agent.
Also adds deprecation warning to Agent import from root path to encourage using the recommended subpath import. (#8584)
@mastra/ai-sdk
@mastra/chroma
- dependencies updates:
- Updated dependency
chromadb@^3.0.17
↗︎ (from^3.0.15
, independencies
) (#8554)
- Updated dependency
@mastra/client-js
@mastra/core
-
workflow run thread more visible (#8539)
-
Add iterationCount to loop condition params (#8579)
-
Mutable shared workflow run state (#8545)
-
avoid refetching memory threads and messages on window focus (#8519)
-
add tripwire reason in playground (#8568)
-
Add validation for index creation (#8552)
-
Save waiting step status in snapshot (#8576)
-
Added AI SDK provider packages to model router for anthropic/google/openai/openrouter/xai (#8559)
-
type fixes and missing changeset (#8545)
-
Convert WorkflowWatchResult to WorkflowResult in workflow graph (#8541)
-
add new deploy to cloud button (#8549)
-
remove icons in entity lists (#8520)
-
add client search to all entities (#8523)
-
Improve JSDoc documentation for Agent (#8389)
-
Properly fix cloudflare randomUUID in global scope issue (#8450)
-
Marked OTEL based telemetry as deprecated. (#8586)
-
Add support for streaming nested agent tools (#8580)
-
Fix TypeScript errors with provider-defined tools by updating ai-v5 and openai-v5 to matching provider-utils versions. This ensures npm deduplicates to a single provider-utils instance, resolving type incompatibility issues when passing provider tools to Agent.
Also adds deprecation warning to Agent import from root path to encourage using the recommended subpath import. (#8584)
-
UX for the agents page (#8517)
-
add icons into playground titles + a link to the entity doc (#8518)
@mastra/dane
- Mutable shared workflow run state (#8545)
@mastra/deployer
-
fix: custom API routes now properly respect authentication requirements
Fixed a critical bug where custom routes were bypassing authentication when they should have been protected by default. The issue was in the
isProtectedPath
function which only checked pattern-based protection but ignored custom route configurations.- Custom routes are now protected by default or when specified with
requiresAuth: true
- Custom routes are now protected by default or when specified with
-
Custom routes properly inherit protection from parent patterns (like
/api/*
) -
Routes with explicit
requiresAuth: false
continue to work as public endpoints -
Enhanced
isProtectedPath
to consider both pattern matching and custom route auth configThis fixes issue #8421 where custom routes were not being properly protected by the authentication system. (#8469)
-
Correctly handle errors in streams. Errors (e.g. rate limiting) before the stream begins are now returned with their code. Mid-stream errors are passed as a chunk (with
type: 'error'
) to the stream. (#8567) -
Mutable shared workflow run state (#8545)
-
Fix bug when lodash dependencies where used in subdependencies (#8537)
@mastra/deployer-cloud
@mastra/deployer-cloudflare
- Mutable shared workflow run state (#8545)
- Properly fix cloudflare randomUUID in global scope issue (#8450)
@mastra/deployer-netlify
- Mutable shared workflow run state (#8545)
@mastra/deployer-vercel
- Mutable shared workflow run state (#8545)
@mastra/dynamodb
- dependencies updates:
- Updated dependency
@aws-sdk/client-dynamodb@^3.902.0
↗︎ (from^3.896.0
, independencies
) - Updated dependency
@aws-sdk/lib-dynamodb@^3.902.0
↗︎ (from^3.896.0
, independencies
) (#8436)
- Updated dependency
@mastra/inngest
@mastra/langsmith
- dependencies updates:
- Updated dependency
langsmith@>=0.3.72
↗︎ (from>=0.3.71
, independencies
) (#8560)
- Updated dependency
@mastra/longmemeval
- Mutable shared workflow run state (#8545)
@mastra/mcp
- Mutable shared workflow run state (#8545)
@mastra/mcp-docs-server
- Mutable shared workflow run state (#8545)
@mastra/memory
-
Ensure working memory can be updated througb createThread and updateThread (#8513)
-
Fix TypeScript errors with provider-defined tools by updating ai-v5 and openai-v5 to matching provider-utils versions. This ensures npm deduplicates to a single provider-utils instance, resolving type incompatibility issues when passing provider tools to Agent.
Also adds deprecation warning to Agent import from root path to encourage using the recommended subpath import. (#8584)
@mastra/pg
- Add validation for index creation (#8552)
@mastra/playground-ui
- workflow run thread more visible (#8539)
- Mutable shared workflow run state (#8545)
- streamLegacy/generateLegacy clarification in playground (#8468)
- add tripwire reason in playground (#8568)
- Save waiting step status in snapshot (#8576)
- Added AI SDK provider packages to model router for anthropic/google/openai/openrouter/xai (#8559)
- type fixes and missing changeset (#8545)
- Convert WorkflowWatchResult to WorkflowResult in workflow graph (#8541)
- remove icons in entity lists (#8520)
- extract mcp servers into playground + use a table instead of custom stuff (#8521)
- add client search to all entities (#8523)
- UX for the agents page (#8517)
- add icons into playground titles + a link to the entity doc (#8518)
@mastra/react
- Mutable shared workflow run state (#8545)
- add tripwire reason in playground (#8568)
- type fixes and missing changeset (#8545)
- Convert WorkflowWatchResult to WorkflowResult in workflow graph (#8541)
@mastra/s3vectors
- dependencies updates:
- Updated dependency
@aws-sdk/client-s3vectors@^3.901.0
↗︎ (from^3.896.0
, independencies
) (#8436)
- Updated dependency
@mastra/server
-
Mutable shared workflow run state (#8545)
-
Fix TypeScript errors with provider-defined tools by updating ai-v5 and openai-v5 to matching provider-utils versions. This ensures npm deduplicates to a single provider-utils instance, resolving type incompatibility issues when passing provider tools to Agent.
Also adds deprecation warning to Agent import from root path to encourage using the recommended subpath import. (#8584)
create-mastra
- Mutable shared workflow run state (#8545)
- streamLegacy/generateLegacy clarification in playground (#8468)
- avoid refetching memory threads and messages on window focus (#8519)
- add tripwire reason in playground (#8568)
- Save waiting step status in snapshot (#8576)
- Added AI SDK provider packages to model router for anthropic/google/openai/openrouter/xai (#8559)
- Convert WorkflowWatchResult to WorkflowResult in workflow graph (#8541)
- Fix useStreamWorkflow unmounting breaking stream call (#8449)
mastra
- workflow run thread more visible (#8539)
- Mutable shared workflow run state (#8545)
- streamLegacy/generateLegacy clarification in playground (#8468)
- avoid refetching memory threads and messages on window focus (#8519)
- add tripwire reason in playground (#8568)
- Save waiting step status in snapshot (#8576)
- Added AI SDK provider packages to model router for anthropic/google/openai/openrouter/xai (#8559)
- Convert WorkflowWatchResult to WorkflowResult in workflow graph (#8541)
- add new deploy to cloud button (#8549)
- remove icons in entity lists (#8520)
- add client search to all entities (#8523)
- Fix useStreamWorkflow unmounting breaking stream call (#8449)
- Remove shell from dev (#8466)
- UX for the agents page (#8517)
- add icons into playground titles + a link to the entity doc (#8518)