Skip to main content
Short-term memory lets your agent remember previous interactions within a single thread or conversation. This guide shows how to use MongoDB Atlas as the persistent checkpointer backend. MongoDB stores conversation state as documents in a collection, so threads can resume across process restarts and deployments.
Need to remember information across conversations? Use long-term memory with MongoDB Atlas to store and recall data across different threads and sessions.

Setup

Installation

Credentials

Set your Atlas connection string:
If you want automated tracing of your model calls, set your LangSmith API key:

Usage

Create a MongoDBSaver with from_conn_string and pass it to create_agent. The context manager creates the required collections and indexes when it opens. You do not call a separate setup() method (unlike the Postgres checkpointer).
MongoDBSaver also exposes async methods such as aget and aput for use in async graphs. There is no separate AsyncMongoDBSaver class.

Next steps