New:Socket for Asana Is Now Available.Learn more
Get Started

@mastra/memory

Package Overview
Dependencies
Maintainers
7
Versions
1122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
This package has malicious versions linked to the ongoing "Mastra AI framework compromise" supply chain attack.

Affected versions:

1.20.4
View campaign page

@mastra/memory

Source
npmnpm
Version
1.28.3
Version published
Weekly downloads
600K
-28.94%
Maintainers
7
Weekly downloads
 
Created
Source

@mastra/memory

@mastra/memory gives Mastra agents persistent conversation history, semantic recall, working memory, and observational memory. Attach a Memory instance to an agent when it should retain context across messages and threads.

Installation

npm install @mastra/memory

Usage

Attach memory to an agent and pass a stable thread and resource ID when generating a response.

import { Agent } from '@mastra/core/agent';
import { Memory } from '@mastra/memory';

const agent = new Agent({
  id: 'support-agent',
  name: 'Support agent',
  instructions: 'Answer support questions using the conversation history.',
  model: 'openai/gpt-5.6-sol',
  memory: new Memory(),
});

const response = await agent.generate('What did we discuss last time?', {
  memory: { thread: 'conversation-123', resource: 'user-456' },
});

Documentation

  • @mastra/memory documentation

Changelog

See the package changelog for version history and release notes.

Support

We have an open community Discord. Come and say hello and let us know if you have any questions or need any help getting things running.

FAQs

Package last updated on 09 Sep 2026

Related posts