Repository navigation
LangChain Integration
Archived: describes an older release that is no longer supported.
Use SuperLocalMemory as a local-first chat message history backend for LangChain applications. All data stays on your machine — zero cloud calls, zero API keys for the memory layer.
Prerequisites: SuperLocalMemory installed (npm install -g superlocalmemory or ./install.sh)
pip install langchain-superlocalmemoryfrom langchain_superlocalmemory import SuperLocalMemoryChatMessageHistory
from langchain_core.messages import HumanMessage, AIMessage
# Create a session
history = SuperLocalMemoryChatMessageHistory(session_id="my-project")
# Add messages
history.add_messages([
HumanMessage(content="I'm building a React app with TypeScript"),
AIMessage(content="Great choice! Do you want to use Next.js or Vite?"),
])
# Messages persist across sessions
messages = history.messages # Returns all messages for this sessionfrom langchain_core.chat_history import InMemoryChatMessageHistory
from langchain_core.runnables.history import RunnableWithMessageHistory
from langchain_superlocalmemory import SuperLocalMemoryChatMessageHistory
# Store factory — returns persistent local memory per session
store = {}
def get_session_history(session_id: str):
if session_id not in store:
store[session_id] = SuperLocalMemoryChatMessageHistory(session_id=session_id)
return store[session_id]
# Wrap your chain with persistent memory
conversation = RunnableWithMessageHistory(
your_chain,
get_session_history,
)
# Each session_id gets isolated, persistent memory
response = conversation.invoke(
"What framework am I using?",
config={"configurable": {"session_id": "my-project"}},
)# Work project
work = SuperLocalMemoryChatMessageHistory(session_id="work-api-redesign")
# Personal project
personal = SuperLocalMemoryChatMessageHistory(session_id="personal-blog")
# Sessions are fully isolated — no cross-contamination| Parameter | Type | Default | Description |
|---|---|---|---|
session_id |
str |
Required | Unique identifier for this conversation session |
db_path |
Optional[str] |
~/.claude-memory/memory.db |
Path to SQLite database |
Methods:
| Method | Returns | Description |
|---|---|---|
.messages |
List[BaseMessage] |
All messages for this session, ordered chronologically |
.add_messages(messages) |
None |
Add one or more messages to the session |
.clear() |
None |
Remove all messages for this session |
- Each message is stored as a memory entry in SLM's SQLite database
- Messages are tagged with
langchain:session:{session_id}for isolation - Content is serialized via LangChain's
message_to_dict()for perfect round-trip fidelity - All message types supported:
HumanMessage,AIMessage,SystemMessage,FunctionMessage,ToolMessage - Importance is set to 3 (lower than user memories) so chat history doesn't crowd search results
SuperLocalMemory: governed, local-first memory for AI agents. Home · Installation · Architecture · Privacy and Data Flow · CLI · MCP tools · FAQ
Part of Qualixar | Created by Varun Pratap Bhardwaj | GitHub · CHANGELOG
Platform boundary: Apple Silicon macOS, 64-bit Windows and 64-bit Linux. Linux covers x86_64 and ARM64. Intel Mac, 32-bit Windows and Windows on ARM are not supported.
SuperLocalMemory
Start here
How memory works
- Architecture
- How Remember Works
- How Recall Works
- Retrieval Score Contract
- Answer Check
- Memory Kinds
- Modes Explained
- Profiles
- Auto-Memory
- Active Memory
The living system
Governance and trust
- Governance
- Security, Company Mode and Teams
- Privacy and Data Flow
- GDPR
- Compliance
- Backup and Restore
- Cloud Backup
Beyond text
Connected systems
- Bots That Talk (SLM-Mesh)
- Connect Web Apps (steps)
- Web Access and Connected Apps
- Bounded Loops
- Framework Adapters
- Optimize
Operate and reference
- Dashboard Tour
- Configuration
- Embedding Models
- CLI Reference
- MCP Tools
- Capabilities and Operations
- Troubleshooting
- FAQ
Research
Archive