Mastra memory
Memory on Mastra’s native processor pipeline: recall before each call, fact extraction from the user’s message after it, per-call identity.
Overview
Install memorysync-mastra and add the processors to any Agent: recalled context is injected as a system message before each generate or stream call and the user’s message is sent to fact extraction after it (only its durable facts are stored; assistant replies are not). Identity resolves per call from four sources (static config, your own resolver, RequestContext, memory.resource), a zero-config wrapper merges the processors into existing configs, and five structured tools give agents explicit memory. Runs on current @mastra/core 1.x.
Setup status and requirements
- Supported version
- memorysync-mastra 1.1.0 (npm)
- Last setup review
- 2026-09-03
- Permissions
- A MemorySync API key with read and write scopes.
- Limits
- Requires @mastra/core 1.42+ (Node 20+ for the package; current @mastra/core itself requires Node 22+). JavaScript/TypeScript only — Python agents use the LangChain, LangGraph or CrewAI integrations.
Capabilities
- Native inputProcessors/outputProcessors — no model wrapping required
- Four identity sources: static, resolver, RequestContext, memory.resource
- No resolved user means nothing is sent — a wrong-scope write is refused loudly
- Streaming-safe: sends once on finish; a failed stream sends nothing
- Recall modes: query, profile, or full
- Five never-throw agent tools with a read-only mode
- CI-tested against a real Agent on the latest @mastra/core 1.x
Quick Start
import { Agent } from "@mastra/core/agent";import { openai } from "@ai-sdk/openai";import { withMemorySync } from "memorysync-mastra";const agent = new Agent(withMemorySync({id: "assistant",name: "Assistant",instructions: "You are a helpful assistant.",model: openai("your-model"),},{ userId: "customer-7" },));const { text } = await agent.generate("Book my usual trip.");
Use Cases
Mastra agents that remember users across threads and deploys
Multi-user agent servers with per-request identity
Agents with explicit memory tools
Guides and related pages
Related integrations
Explore More
Add long-term memory to Mastra
Start free with 10,000 add requests a month and no credit card. Memory is stored per end user and comes back in every later session.
