Local persistent memory store for LLM applications including claude desktop, github copilot, codex, antigravity, etc.
Local persistent memory store for LLM applications including claude desktop, github copilot, codex, antigravity, etc.
Durable, temporal, governed memory for AI agents. Not just RAG. Not just a vector database. Local-first and self-hosted.
LongMemory is a cognitive memory engine for LLM applications and autonomous agents.
Your model stays stateless. Your application stops being amnesiac.
npm install longmemoryimport { 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.
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.
npm install --global longmemory
longmemory init
longmemory recall "current project priorities" --mode associativepip install longmemory-sdkfrom 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.
git clone https://github.com/CaviraOSS/LongMemory.git
cd LongMemory
corepack enable
pnpm install --frozen-lockfile
pnpm build
pnpm startThe API listens on http://127.0.0.1:7331 by default.
docker run --rm \
-p 7331:7331 \
-v longmemory-data:/data \
-e LONGMEMORY_API_KEY=change-me \
ghcr.io/caviraoss/longmemory:latestcp .env.example .env
docker compose up --build -d longmemoryInclude the dashboard:
docker compose --profile ui up --build -dhttp://127.0.0.1:7331http://127.0.0.1:3000http://127.0.0.1:7331/healthMost systems called memory are retrieval pipelines:
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:
See Why.md for the design rationale.
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.
Start local stdio MCP:
longmemory mcp --db .longmemory/project.db --project currentExpose authenticated Streamable HTTP MCP:
LONGMEMORY_API_KEY=change-me longmemory serve --mcp-httpLongMemory exposes 13 high-level governed tools plus readable resources and agent workflow prompts. Tool arguments cannot override server-bound runtime identity.
Installable integrations include:
See integrations/README.md and docs/mcp.md.
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, open tasks, failures, code facts, matched Skills, conflicts, and governed asset loadouts under one token budget.
…Finite commands emit stable JSON outside a TTY or when --json is supplied. The session porter reads supported coding-agent stores without modifying them. See docs/cli.md.
The Next.js dashboard provides health, memory browsing, ingestion, search, project selection, activity, decay, settings, timelines, and memory-aware chat through a same-origin API proxy.
pnpm --dir dashboard build
pnpm --dir dashboard startThe VS Code extension provides an activity-bar browser, status bar, recall, project context, explanation, reinforcement, explicit decay, session import, and reviewed AI-change capture.
pnpm extension:packageThe generated package is apps/vscode-extension/longmemory-vscode-0.2.0.vsix.
…Read ARCHITECTURE.md and docs/architecture.md for subsystem details.
| Platform | Configuration | What it deploys |
|---|---|---|
| Docker | Dockerfile |
API and Streamable HTTP MCP |
| Docker Compose | docker-compose.yml |
API/MCP plus optional dashboard |
| Heroku | app.json |
Containerized API/MCP |
| Railway | railway.json |
Containerized API/MCP |
| Render | render.yaml |
API/MCP with persistent disk |
| DigitalOcean | .do/spec.yaml |
App Platform API/MCP service |
| Vercel | vercel.json |
Dashboard; configure LONGMEMORY_API_URL |
| Windows | start-longmemory.ps1 |
Background local API/MCP process |
For hosted API deployments, set LONGMEMORY_API_KEY, mount persistent storage at /data, and terminate TLS at the platform edge. Vercel hosts only the stateless dashboard and requires a separately deployed LongMemory API.
pnpm bench
pnpm bench:ci
pnpm bench:fullThe benchmark harness publishes explicit manifests, dataset completion, evidence metrics, answer judgments, temporal categories, latency percentiles, and N/A reasons. Official scorecards fail closed on incomplete datasets or semantic embedding fallback. See benchmarks/README.md.
Import supported SQLite, JSON, or JSONL memory:
longmemory migrate \
--from ./legacy.db \
--to ./longmemory.db \
--report ./migration-report.jsonImport coding-agent conversations as governed Chat Memory:
longmemory port --from codex --to longmemory --allSee MIGRATION.md and docs/migration.md.
Legacy package migration:
npm uninstall openmemory-js && npm install longmemory
pip uninstall openmemory-py && pip install longmemory-sdkopenmemory-js@2 and openmemory-py@2 are forwarding bridges for existing installations. New applications should use longmemory and longmemory-sdk directly. PyPI's unrelated longmemory name is owned by another project, so the official distribution is longmemory-sdk while the import remains longmemory.
corepack enable
pnpm install --frozen-lockfile
pnpm release:check
pnpm pack
pnpm extension:packagerelease:check validates branding, types, integration manifests, the benchmark smoke gate, the root build, extension build, and dashboard production build.
Useful Make targets:
make install
make build
make check
make docker-up
make dashboardLongMemory is local-first, but network deployment still requires explicit controls:
LONGMEMORY_API_KEY.No open issues yet, or sync has not completed.