LongMemory is a free, open source machine learning infrastructure project written in TypeScript and released under Apache-2.0. It has 4,502 GitHub stars, 504 forks and 19 open issues, and was last pushed 4 days ago. On this registry it ranks #34 of 57 tracked projects in Machine Learning Infrastructure, with 5 head-to-head comparisons available.

What is LongMemory?

LongMemory is a local-first, self-hosted cognitive memory engine for LLM applications and autonomous agents that gives stateless models durable, temporal, governed recall, written in TypeScript under the Apache-2.0 licence and aimed at developers building agent hosts, automation tools, and RAG-style pipelines.

What it is

LongMemory is a cognitive memory engine for LLM applications and autonomous agents. It provides durable local-first storage on SQLite, immutable content with provenance and temporal truth, and governed project memory that spans Skills, Chat Memory, LLM-Wiki, and CodeGraph. A single TypeScript engine is exposed consistently across an npm library, a CLI, an HTTP API, an MCP server, a dashboard, and a VS Code extension, with native integrations for agent hosts, automation tools, and Python frameworks. Its stated design goal is that the model stays stateless while the application stops being amnesiac.

The concrete problem it solves is the gap left by systems that call themselves memory but are retrieval pipelines: split text into chunks, embed the chunks, return the nearest vectors. That approach does not establish what was true at a particular time, whether a new fact superseded an older one, which source is authoritative, who is permitted to see a given item, or why a result belongs in the context window at all. LongMemory models those concerns directly rather than leaving them to the caller. It lives in the AI and machine learning infrastructure ecosystem as a self-hosted memory layer for agent stacks, including Claude Desktop, GitHub Copilot, Codex, and Antigravity, and it replaces the nearest-vector retrieval pattern as the application's memory substrate.

Key capabilities

  • Models temporal truth alongside immutable content and provenance, so recorded time and source authority are first-class rather than metadata afterthoughts.
  • Offers five distinct recall modes — strict, historical, associative, grounded, and multilingual — instead of a single similarity search.
  • Provides explainable evidence selection with token-bounded context, so the reason a result enters the prompt is inspectable.
  • Governs project memory across Skills, Chat Memory, LLM-Wiki, and CodeGraph.
  • Ships one TypeScript engine surfaced identically through the longmemory npm package, the CLI, the HTTP API, MCP, the dashboard, and the VS Code extension.
  • Exposes an optional answer_from_evidence adapter that accepts authorized evidence, validates cited excerpts, and makes at most one model call; policies live in docs/answering.md.
  • Publishes longmemory-sdk on PyPI as a zero-dependency HTTP client, while the Hydrograph engine stays in the self-hosted TypeScript service.

Who uses it and how

  • Agent-host users on Claude Desktop, GitHub Copilot, Codex, and Antigravity connect over MCP to give those hosts persistent recall.
  • Small teams self-host the HTTP service on http://127.0.0.1:7331, setting LONGMEMORY_API_KEY and mounting a longmemory-data volume for the SQLite database.
  • Multi-tenant deployments scope storage with tenant_id and user_id at createMemory time, so one database holds separated user memory.
  • Python framework developers call the engine from Python through LongMemory("http://127.0.0.1:7331", api_key=..., user_id=...) while the engine itself remains self-hosted TypeScript.
  • Command-line and editor workflows use longmemory recall "current project priorities" --mode associative or the VS Code extension, with the dashboard available on port 3000 under the ui compose profile.

Getting started

Install the library with npm install longmemory for in-process use with no service or external database, or run the service with docker run -p 7331:7331 -v longmemory-data:/data -e LONGMEMORY_API_KEY=change-me ghcr.io/caviraoss/longmemory:latest. From source, corepack enable, pnpm install --frozen-lockfile, pnpm build, and pnpm start; Docker Compose users run docker compose up --build -d longmemory, and Python clients install longmemory-sdk.

How it compares

No comparable tools or paid products are named in the facts provided for this listing, so LongMemory stands alone in this registry on that axis.

When to use it — and when not to

A self-hoster operates the HTTP service, the SQLite database or mounted volume, the API key secret, port 7331, and optionally the dashboard and the pnpm build toolchain. Teams that want a fully managed memory service with no infrastructure to run should not pick it, since local-first and self-hosted operation are the design premise. The listing's README excerpt is also truncated mid-sentence in the temporal truth section, so some governance and answering-policy detail cannot be verified from this page alone and should be read in the repository documentation.

project readme (upstream, from github) — read inline

LongMemory

Durable, temporal, governed memory for AI agents. Not just RAG. Not just a vector database. Local-first and self-hosted.

npm PyPI VS Code Container License

LongMemory dashboard

LongMemory is a cognitive memory engine for LLM applications and autonomous agents.

  • Durable local-first storage with SQLite
  • Immutable content, provenance, and temporal truth
  • Strict, historical, associative, grounded, and multilingual recall
  • Explainable evidence selection and token-bounded context
  • Governed project memory, Skills, Chat Memory, LLM-Wiki, and CodeGraph
  • One TypeScript engine across npm, CLI, HTTP, MCP, dashboard, and VS Code
  • Native integrations for agent hosts, automation tools, and Python frameworks

Your model stays stateless. Your application stops being amnesiac.


1. Use It in 10 Seconds

Install as a library

npm install longmemory
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();

No service or external database is required for in-memory use.

For optional evidence-grounded answers with your own model, use the exported answer_from_evidence adapter. It accepts authorized evidence, validates cited excerpts, and makes at most one model call; ordinary recall is unchanged. See docs/answering.md for policies, limits, and integration.

Persist with SQLite

const memory = await createMemory({
    store: 'sqlite',
    db_path: './longmemory.db',
    tenant_id: 'acme',
    user_id: 'alice',
});

Reopening the same database restores nodes, worlds, entities, edges, temporal history, grounding, and lifecycle state.

Install the CLI

npm install --global longmemory
longmemory init
longmemory recall "current project priorities" --mode associative

Call a self-hosted server from Python

pip install longmemory-sdk
from longmemory import LongMemory

memory = LongMemory(
    "http://127.0.0.1:7331",
    api_key="change-me",
    user_id="alice",
)

memory.ingest("I prefer TypeScript")
result = memory.recall("What language do I prefer?", mode="strict")

The Python package is a zero-dependency HTTP client. The Hydrograph engine remains in the self-hosted TypeScript service. See docs/python-sdk.md.


2. Run as a Service

From source

git clone https://github.com/CaviraOSS/LongMemory.git
cd LongMemory
corepack enable
pnpm install --frozen-lockfile
pnpm build
pnpm start

The API listens on http://127.0.0.1:7331 by default.

Docker

docker run --rm \
  -p 7331:7331 \
  -v longmemory-data:/data \
  -e LONGMEMORY_API_KEY=change-me \
  ghcr.io/caviraoss/longmemory:latest

Docker Compose

cp .env.example .env
docker compose up --build -d longmemory

Include the dashboard:

docker compose --profile ui up --build -d
  • API and MCP: http://127.0.0.1:7331
  • Dashboard: http://127.0.0.1:3000
  • Health: http://127.0.0.1:7331/health

3. Why LongMemory

Most systems called memory are retrieval pipelines:

  1. Split text into chunks.
  2. Embed the chunks.
  3. Return the nearest vectors.

That does not establish what was true at a particular time, whether a new fact superseded an old one, which source is authoritative, who may see it, or why a result belongs in context.

LongMemory models those concerns directly:

  • Temporal truth: recorded time and valid time are separate.
  • Immutable memory: content, vectors, hashes, and provenance are not rewritten by recall or decay.
  • Executable graph: typed relationships participate in recall and explanation.
  • Governance: project, tenant, user, team, role, agent, task, and framework scope are enforced.
  • Lifecycle: deterministic decay, explicit reinforcement, consolidation, compression, and reconsolidation.
  • Evidence: recall is bounded by relevance, contradictions, grounding, permissions, and token cost.

See Why.md for the design rationale.


4. Recall Modes

const strict = await memory.recall({
    text: 'What is the current deployment region?',
    mode: 'strict',
});

const historical = await memory.recall({
    text: 'What was the deployment region in January?',
    mode: 'historical',
    valid_time: Date.UTC(2026, 0, 15),
});

const associative = await memory.recall({
    text: 'Incidents related to the payment migration',
    mode: 'associative',
});

const grounded = await memory.recall({
    text: 'Which production endpoint is currently live?',
    mode: 'world_grounded',
});

Strict recall applies temporal, contradiction, contract, confidence, and grounding gates. Historical recall preserves superseded truth. Associative recall follows semantic, lexical, entity, activation, and graph signals. World-grounded recall requires current external evidence.


5. Features

  • Hydrograph memory substrate with immutable nodes, executable edges, worlds, entities, facets, and traces.
  • Temporal reasoning with point-in-time truth, event ordering, supersession, and stale-evidence controls.
  • Multilingual memory with script detection, code switching, transliteration, and cross-language embeddings.
  • Project memory for architecture, decisions, tasks, conventions, failures, handoffs, and code impact.
  • Governed assets for Chat Memory, Skills, LLM-Wiki, and CodeGraph with lifecycle and ACL policy.
  • Session porter for Claude Code, Codex, OpenCode, Gemini CLI, Copilot Chat, Cline, and raw harness logs.
  • Connectors for repositories, local files, Markdown, web content, feeds, cloud documents, and provider APIs.
  • Embeddings through OpenAI-compatible APIs, Gemini, AWS Bedrock, Ollama, Siray, and local HTTP models.
  • Operational surfaces through HTTP, MCP, dashboard, VS Code, n8n, and framework-native MCP clients.
  • Auditable benchmarks for LongMemEval, LoCoMo, BEAM, retrieval quality, temporal behavior, and latency.

6. MCP and Agent Integrations

Start local stdio MCP:

longmemory mcp --db .longmemory/project.db --project current

Expose authenticated Streamable HTTP MCP:

LONGMEMORY_API_KEY=change-me longmemory serve --mcp-http

LongMemory exposes 13 high-level governed tools plus readable resources and agent workflow prompts. Tool arguments cannot override server-bound runtime identity.

Installable integrations include:

  • Claude Code plugin
  • Codex and ChatGPT desktop plugin
  • Gemini CLI extension
  • Agent Plugins 1.0 bundle for OpenClaw and compatible hosts
  • n8n community node usable as an AI Agent tool
  • Cline, Continue, and LibreChat configuration packs
  • Dify and Flowise native MCP setup
  • CrewAI, AutoGen, LangGraph/LangChain, OpenAI Agents SDK, and PydanticAI examples

See integrations/README.md and docs/mcp.md.


7. Temporal and Project Memory

import { createProjectMemory } from 'longmemory';

const projects = await createProjectMemory({
    tenant_id: 'cavira',
    organization_id: 'CaviraOSS',
    project_id: 'longmemory',
    name: 'LongMemory',
    store: 'sqlite',
    db_path: './longmemory.db',
});

await projects.ingestProjectEvent('longmemory', {
    kind: 'decision',
    topic: 'persistence',
    text: 'Use SQLite for local-first persistence',
    source_type: 'architecture_note',
});

const context = await projects.getProjectContext('longmemory', 'prepare the next release');

Project context combines relevant architecture, current decisions, op

readme truncated — read the full docs on github

Frequently asked questions

Is LongMemory free to use?

LongMemory is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does LongMemory do?

Local persistent memory store for LLM applications including claude desktop, github copilot, codex, antigravity, etc.

What is LongMemory written in?

LongMemory is primarily written in TypeScript. Its source is publicly available at https://github.com/CaviraOSS/LongMemory, and it has 4,502 GitHub stars.