Overview
LongMemory is a memory engine for LLM applications and autonomous agents. The pitch in its own README is that it is neither plain RAG nor a bare vector database: content is stored immutably with provenance and a temporal history, so the store can answer not just "what do I know" but "what was true when", and it can show the evidence it used to answer.
Everything runs local-first. The default store is SQLite on your own disk, and reopening the same database restores nodes, worlds, entities, edges, temporal history, grounding and lifecycle state. Recall is token-bounded and comes in several modes — strict, historical, associative, grounded and multilingual — so the caller decides how much context to spend and how literal the match must be.
One TypeScript engine is exposed through every surface a team is likely to want: an npm library, a global CLI, an HTTP service, an MCP server for agent hosts such as Claude Desktop, GitHub Copilot and Codex, a dashboard, and a VS Code extension. A zero-dependency Python SDK talks to the self-hosted service over HTTP. The project is Apache-2.0 licensed.
What it does
- Durable local-first storage on SQLite, with immutable content, provenance and temporal truth rather than overwritten facts
- Five recall modes — strict, historical, associative, grounded and multilingual — with explainable evidence selection and token-bounded context
- One TypeScript engine across npm, a CLI, HTTP, MCP, a dashboard and a VS Code extension
- Governed project memory plus Skills, Chat Memory, LLM-Wiki and CodeGraph layers
- Zero-dependency Python SDK that calls the self-hosted service, keeping the engine in one place
- Optional answer_from_evidence adapter that validates cited excerpts and makes at most one model call, leaving ordinary recall untouched
Getting started
The in-memory path needs no service and no external database, so you can ingest and recall inside a single Node process before deciding how to deploy.
Install as a library
npm install longmemoryIngest and recall
createMemory returns an engine; ingest writes a fact for a user, recall queries it with a mode.
import { createMemory } from 'longmemory';
const memory = await createMemory();
await memory.ingest({
user_id: 'alice',
text: 'I prefer TypeScript for backend services',
});
const result = await memory.recall({
text: 'What language does Alice prefer?',
mode: 'strict',
});
console.log(result);
await memory.close();Persist to SQLite
Point the store at a file and the graph survives restarts, scoped by tenant and user.
const memory = await createMemory({
store: 'sqlite',
db_path: './longmemory.db',
tenant_id: 'acme',
user_id: 'alice',
});Use the CLI
The same engine is available globally for shell use and scripting.
npm install --global longmemory
longmemory init
longmemory recall "current project priorities" --mode associativeCall a self-hosted server from Python
The Python package is a thin HTTP client; the engine stays in the self-hosted TypeScript service.
pip install longmemory-sdkCommands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Give a chat assistant memory that survives sessions without pushing user data to a hosted memory service
- Answer questions that depend on when something was true, using historical recall over an immutable, provenance-tagged store
- Share one memory store across Claude Desktop, Copilot and Codex by pointing each at the same MCP server
- Keep a project's governed memory — decisions, skills, code graph — beside the repo instead of in a vendor account
How LongMemory compares
LongMemory alongside other open-source agent memory tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Claude-Mem | ★ 94.3k | Persistent memory layer for coding agents: it captures what an agent does during a session, compresses it into semantic summaries, and injects the relevant parts back into later sessions. |
| Mem0 | ★ 65.7k | A memory layer that you add to existing LLM agents to extract, store, and recall user facts and preferences across sessions using vector, graph, and key-value backends. |
| MemPalace | ★ 59.2k | Local-first agent memory that stores conversations verbatim instead of summarising them, with a structured palace index, pluggable vector backends and an MCP server. |
| OpenViking | ★ 38.1k | A context database that stores an agent's memories, resources, and skills as one browsable viking:// filesystem with three-tier (abstract/overview/details) on-demand loading. |
| Graphiti | ★ 31k | A library that builds a temporal knowledge graph from an agent's conversations and data so facts can be tracked and queried as they change over time. |
| Cognee | ★ 30.8k | A graph-native memory engine that turns raw documents and conversations into a queryable knowledge graph for agents that need to build lasting knowledge. |
| Supermemory | ★ 30.6k | A memory and context engine that ingests information across tools and sessions and can run fully locally, acting as a second brain for AI applications. |
| LongMemory | ★ 4.5k | Durable, temporal, governed memory for AI agents — local-first |