OpenMemory Documentation
repository·main·Indexed 26 days ago
https://github.com/caviraoss/openmemoryA cognitive memory engine for LLMs and agents providing long-term, self-hosted, and explainable memory. It supports temporal reasoning, multi-sector memory (episodic, semantic, procedural, emotional, reflective), and decay/reinforcement mechanisms. The project includes a JavaScript library (openmemory-js), a Python SDK (openmemory-py), a VSCode extension for AI assistant context, and a management dashboard. It features integrations with OpenAI, LangChain, and the Model Context Protocol (MCP), as well as connectors for GitHub, Notion, and Google Drive.
What's inside OpenMemory
- OpenMemory is a self-hosted AI memory engine that implements the Hierarchical Memory Decomposition (HMD) v2 architecture. It is designed to provide persistent, structured, and semantic memory for LLM applications using multi-sector embeddings and single-waypoint graph linking.
Understand OpenMemory's Architectural Differences
mainUnlike standard Vector Databases that store flat embeddings and rely solely on cosine similarity, OpenMemory uses a multi-sector cognitive engine (HMD v2).
Key architectural features include:
- Memory Sectors: Information is categorized into episodic, semantic, procedural, emotional, and reflective sectors.
- Single-Waypoint Graph: Automatically creates a single, strongest connection between related memories to enable explainable recall.
- Composite Similarity: Retrieval uses both similarity and activation spreading across sectors.
- Temporal Awareness: Built-in recency and salience scoring for memory decay and reinforcement.
- Local-First: Uses SQLite and FAISS/Chroma locally, making it highly efficient and private.
Understand Temporal Graph capabilities
mainOpenMemory treats time as a first-class citizen via a Temporal Graph. It tracks the following metadata to enable time-based querying:
- Creation Time: When the memory was first recorded.
- Last Access: The last time the memory was retrieved (used to calculate decay).
- Sequence: The causal chain of events (e.g., Chat History).
This enables temporal queries such as retrieving information from a specific timeframe or determining the sequence of events leading up to a specific interaction.
Understand User Partitioning and Security
mainOpenMemory enforces strict data isolation through user partitioning. All memories are partitioned by auser_id. This ensures that in multi-user environments (such as SaaS applications), memory data from one user is never accessible to another.OpenMemory System Components and Data Flow
mainThe OpenMemory system is organized into several layers and core components:
Client Layer
Users interact with OpenMemory via:
- HTTP Clients
- JavaScript SDK
- Python SDK
- LangGraph Apps
Backend Services
All client requests are handled by a REST API Server (TypeScript/Node) running on Port 8080.
Core Engine Components
- HSG Memory Engine: Handles classification, encoding, storage, querying, decay, and reinforcement of memories.
- Embedding Processor: Supports multiple embedding providers including OpenAI, Gemini, AWS, Ollama, and Local/Synthetic models via a Batch API.
- Ingestion Pipeline: Processes raw data through PDF parsing, DOCX parsing, URL scraping, and text chunking.
Storage Layer
- Database (SQLite): Stores
memories,vectors,waypoints, andembed_logs. - Waypoint Graph: Manages single-waypoint auto-linking, reinforcement, and pruning.
Understand OpenMemory's Memory Types
mainOpenMemory implements a cognitive architecture with three distinct memory types:
- Episodic Memory: Stores specific events and individual interactions.
- Semantic Memory: Stores generalized facts and knowledge extracted from episodic data.
- Procedural Memory: (Planned) Intended for storing "how-to" knowledge and tool usage instructions.
Check LLM compatibility with OpenMemory
mainOpenMemory is model-agnostic. It can be integrated with any Large Language Model (LLM), including:
- Cloud providers (e.g., OpenAI, Anthropic)
- Local models (e.g., Llama 3 via Ollama)
Compare OpenMemory with Vector Databases (Chroma/Pinecone)
mainOpenMemory is designed as an agentic memory layer rather than a standard vector database. Unlike Chroma or Pinecone, OpenMemory provides built-in management for:
- User separation: Keeping memories isolated between different users.
- Temporal tracking: Managing the timeline of information.
- Memory dynamics: Handling automated processes like memory decay and reinforcement.
Understand OpenMemory Architecture
mainOpenMemory utilizes Hierarchical Memory Decomposition combined with a Temporal Graph.
Key architectural components include:
- Sector Classifier: Routes inputs into specific memory sectors (Episodic, Semantic, Procedural, Emotional, or Reflective).
- Recall Engine: Performs retrieval using Vector Search, Waypoint Graphs, Composite Scoring, and a Decay Engine.
- Temporal KG (Knowledge Graph): Manages Facts and Timelines.
- Storage: Uses SQLite or Postgres to store memories, vectors, and waypoints.
- Processes: Includes Embedding, Consolidation, and Reflection to refine memory and output recall traces.
Understand OpenMemory's Hierarchical Storage Graph (HSG)
mainOpenMemory organizes data using a Hierarchical Storage Graph (HSG) rather than a flat vector index. This structure allows for domain-specific organization and relationship mapping:
- Sectors: High-level domains used to categorize memory (e.g.,
Personal,Work,Code). - Nodes: Individual memory units.
- Edges: Relationships between memories, which can be temporal, semantic, or based on explicit entities.
- Sectors: High-level domains used to categorize memory (e.g.,
Quickstart with OpenMemory Python SDK
mainInstall the
openmemory-pypackage to use OpenMemory locally with Python. The SDK is local-first and uses SQLite by default. Note thatadd,search,get, anddeleteare asynchronous methods and must be awaited in async contexts.pip install openmemory-pyfrom openmemory.client import Memory mem = Memory() await mem.add("user prefers dark mode", user_id="u1") results = await mem.search("preferences", user_id="u1") await mem.delete("memory_id")Quickstart with OpenMemory Node/JavaScript SDK
mainInstall
openmemory-jsfor use in Node.js backends, CLIs, or local tools. The SDK is local-first and supports asynchronous operations.npm install openmemory-jsimport { Memory } from "openmemory-js" const mem = new Memory() await mem.add("user likes spicy food", { user_id: "u1" }) const results = await mem.search("food?", { user_id: "u1" }) await mem.delete("memory_id")