Proposal: Encrypted Memory Modules for LangChain (Redis + MongoDB)

Hi everyone, I’m Hemant Kumar from India.

While building CuraDocs, an AI healthcare platform, I encountered a major limitation in LangChain’s memory system:

Problem

All existing LangChain memory backends—Redis, MongoDB, Postgres—store chat history in plaintext.

For teams handling medical data, financial conversations, enterprise workflows, or any form of PII, this makes the default memory adapters unsafe for production use.

Because of this, many teams cannot adopt LangChain memory directly.

Proposal

Introduce encrypted memory modules for LangChain, providing secure, drop-in alternatives to the existing backends.

These modules are already fully implemented, tested, documented, and available as open-source packages:

1. Encrypted Redis Memory (langchain-encrypted-redis-memory)

A secure replacement for RedisChatMessageHistory that encrypts every stored message using AES-128 (Fernet).

:check_mark: Same API — no integration changes
:check_mark: Transparent encryption/decryption
:check_mark: Ideal for short-term memory in RAG and agent pipelines

PyPI:
https://pypi.org/project/langchain-encrypted-redis-memory/

GitHub:
https://github.com/HATAKEkakshi/langchain-encrypted-redis-memory.git

2. Encrypted MongoDB Memory (langchain-encrypted-mongo-memory)

A persistent, encrypted alternative to MongoDBChatMessageHistory, suited for long-term chat storage.

:check_mark: AES-128 encrypted message storage
:check_mark: Protects message content + session identifiers
:check_mark: Designed for production copilots in healthcare, finance, and enterprise

PyPI:
https://pypi.org/project/langchain-encrypted-mongo-memory/

GitHub:
https://github.com/HATAKEkakshi/langchain-encrypted-mongo-memory.git

Integration Guide

A full Jupyter notebook demonstrating encrypted memory with LangChain:

:link:
https://github.com/HATAKEkakshi/integration-guide/blob/main/examples/langchain-encrypted-memory-example.ipynb

The guide includes:

  • Using encrypted Redis & MongoDB memory

  • Retrieving decrypted messages

  • Best practices (hashed session IDs)

  • Comparison with plaintext memory

Category Requested

New Proposal → Memory → Security → Encrypted Chat Memory History

Happy to collaborate and refine structure, naming, or implementation details based on maintainer feedback.

Thanks for reviewing this proposal—looking forward to your thoughts!

Hemant Kumar

Hi @HATAKEkakshi ,

We offer encryption as part of langgraph checkpointing. Documentation is available here: Persistence - Docs by LangChain

We recommend that all applications use langgraph checkpointing for memory (not ChatMessageHistory, which is a very old implementation of memory at this point).

All the best,

Eugene