How to Add Persistent Memory to LangChain Agents
LangChain agents are powerful, but they forget everything between sessions. Here's how to give them persistent, searchable memory in one line of code.
The Problem
Out of the box, LangChain's ConversationBufferMemory lives in process memory. That means:
- ✗Memory is lost every time the process restarts
- ✗Users have to repeat context in every new session
- ✗No way to search past conversations semantically
- ✗No audit trail or rollback if the agent learns something wrong
The Solution: Novyx
novyx-langchain is a drop-in replacement for LangChain's memory classes. Swap one import, and your agent gets persistent memory that survives restarts, supports semantic search, and includes a full audit trail.
Quick Start
Install the integration package:
pip install novyx-langchainAdd persistent memory to your chain:
from novyx_langchain import NovyxMemory
from langchain.chains import ConversationChain
from langchain_openai import ChatOpenAI
# One line to add persistent memory
memory = NovyxMemory(api_key="YOUR_API_KEY", session_id="user-123")
chain = ConversationChain(llm=ChatOpenAI(), memory=memory)
# Your agent now remembers across sessions
response = chain.invoke({"input": "I prefer dark mode"})
# Next session — agent still knows
response = chain.invoke({"input": "What are my preferences?"})
# "You prefer dark mode"What You Get
Persistent Memory
Conversation history survives process restarts, deploys, and server crashes. Pick up right where you left off.
Semantic Search
Recall relevant memories by meaning, not just keywords. Your agent finds what matters.
Point-in-Time Rollback
Made a mistake? Roll back memory to any previous state. Undo bad learning instantly.
Audit Trail
Every memory write is cryptographically signed (SHA-256 + RSA). Full traceability for compliance.
How It Works
Install & configure
Install novyx-langchain and pass your API key. No infrastructure to manage.
Replace the memory class
Swap ConversationBufferMemory for NovyxMemory. The rest of your LangChain code stays the same.
Memories sync automatically
Every conversation turn is stored, indexed, and made searchable. Query history from any session.
Frequently Asked Questions
How do I add persistent memory to a LangChain agent?
Install novyx-langchain with pip, then replace ConversationBufferMemory with NovyxMemory. Your agent's memory persists across sessions, survives restarts, and supports semantic search and rollback.
Does LangChain have built-in persistent memory?
No. LangChain's default memory backends (ConversationBufferMemory, ConversationSummaryMemory) live in process memory and are lost on restart. Novyx provides persistent, searchable memory as a drop-in replacement.
Can I use Novyx with LangGraph?
Yes. novyx-langchain includes a LangGraph checkpointer for stateful workflow persistence. Your graph state survives process restarts and can be rolled back to any checkpoint.
Is Novyx memory searchable in LangChain?
Yes. NovyxMemory uses semantic vector search — your agent can recall relevant past context by meaning, not just keyword matching. Results include relevance scores.
See all framework integrations on the Integrations page, or read the full Python SDK docs.
Start Building with Persistent Memory
5,000 memories free. No credit card required.