AnnouncementBuilt for unpredictable AI demand: Atlas Infinite and MongoDB 9.0 are here. Read more >  >>
AnnouncementMeet the intelligent data platform built for the AI era. Read more > >>
NewNow in public preview: Atlas Agent Engine, the secure way to run AI agents at scale. Read more > >>

Introducing the MongoDB Vercel AI SDK Integration: Persistent Memory for AI Applications

November 5, 2026 ・ 4 min read

We are excited to announce the release of the MongoDB Vercel AI SDK integration, which provides AI applications and agents built with Vercel’s SDK with a persistent memory store in MongoDB Atlas. It's now open source and generally available on npm.

This integration adds MongoDB Atlas as the memory store in the existing Vercel AI SDK code. Once installed, the package connects Vercel AI SDK applications to MongoDB Atlas and automatically stores the application's memories in documents. This allows the application to retain memories about conversations, user facts, and past events that persist across sessions, users, and restarts.

What is the Vercel AI SDK?

The Vercel AI SDK is a TypeScript toolkit for building AI applications. It handles calling models, streaming responses, using tools, and running agents that work through multi-step tasks. The SDK doesn't include a database to persist memories between runs. Without memory, an AI application starts every conversation with no knowledge of the last one. It doesn't know who the user is, what they asked yesterday, or what it learned along the way. It doesn’t have any context.

Today, developers have to build their own tooling to store memories in a layer. That usually means designing a database schema, writing jobs to clear out old data, and setting up vector search so the application can find relevant past information by semantic meaning instead of just keywords. It's a lot of work to build an AI application that can remember context.

What types of memory does an AI application need?

An AI application needs five kinds of memory, each kept for a different length of time and retrieved differently. This integration automatically categorizes each type of memory and stores it in MongoDB Atlas; here are short definitions of the five memory types:

  • Session: The conversation an application or agent has in each session. This helps the application follow what the user just said.

  • Semantic: Facts about people, entities, and preferences, so users don't have to repeat themselves.

  • Procedural: Workflows and instructions, so the application carries out tasks the way you've defined them.

  • Episodic: Key events and outcomes, so the application can recall what happened before. Kept for one year of inactivity by default.

  • Scratchpad: Temporary notes for work in progress. They expire after an hour and can be promoted to episodic memory if they turn out to matter.

Semantic and procedural memories are versioned, so history is preserved when a fact changes. The semantic, procedural, and episodic tiers use MongoDB Vector Search, which finds stored memories by semantic meaning rather than by exact keywords.

This integration automatically creates the vector indexes and detects embedding dimensions at startup. Developers can use any AI SDK embedding model to create vector indexes, including Voyage AI, OpenAI, Cohere, or Google.

Figure 1. How the integration works with MongoDB Atlas and the Vercel SDK interface.

Architecture diagram showing the data flow between users and applications (such as Next.js on Vercel), the Vercel AI SDK (managing and retrieving session, semantic, and user memories with MongoDB integration), and MongoDB Atlas (storing conversation history, vector search, user profiles, and metadata).

How should memory age?

Each category of memory has its own retention policy, so short-lived notes expire quickly, and long-term facts are stored for longer. The MongoDB Vercel AI SDK integration ships with defaults for every category, which developers can customize if they desire.

Effective memory retention requires a balance. Keeping memories indefinitely can decrease retrieval performance and increase costs, while deleting them too early can cause applications to forget important context. This integration includes features to help developers easily set the right balance:

  • Retention modes: Choose none (never expire), ttl (expire after a set time), ttl+importance (expire after a set time unless the memory is marked important), or dynamic, where you define your own forgetting time period.
  • Model-driven forgetting: With memory_forget, the model can delete a specific memory when a user says "forget that." Removal usually happens within about 60 seconds.

Because the memory is stored in MongoDB Atlas, application operational data, its memory, and the vector search that retrieves it run on one platform. Developers can secure, monitor, and scale a single database without bolting on a separate vector store or memory service alongside it.

What changes when you run the MongoDB Vercel AI SDK Integration in production?

This production release gives developers greater controls over their data and flexibility in how they use the integration:

  • Reliable session history: By default, the model decides when to save and read conversation turns, so it can occasionally skip one. For production, you can use the AI SDK hooks so that the application’s own code loads and saves the transcript at every turn. Every user, assistant, and tool message is saved exactly once.

  • Separate data per customer: Developers can add a filter field, such as tenant_id, to the application’s vector indexes to limit each search to a single customer's memories.

  • Application names and layout: Developers can rename collections and indexes to match the existing application schema or turn off indexing for unused categories. 

  • Open source: The package is licensed under Apache 2.0 and works with any AI SDK model.

Get started today

Developers can add memory to an existing Vercel AI SDK project in three steps. This integration works with AI SDK v6 and v7 and requires a MongoDB Atlas cluster.

  1. Install the package and its peer dependencies: npm install @mongodb-developer/vercel-ai-memory ai mongodd

  2. Create a memory instance with an Atlas connection string and an embedding model.

  3. Pass the memory tools to the application, scoped to a user and session.

TypeScript

From there, the model decides when to save and when to search for memories.

megaphone
Next Steps

Ready to add memory to your application?

Start with the Vercel AI SDK memory documentation. For more details, see the following resources:

@mongodb-developer/vercel-ai-memory on npm: The package.

GitHub repository: Source code and examples.

MongoDB Resources