Python 包只是零依赖 HTTP 客户端,引擎仍在自托管 TypeScript 服务里;服务默认端口 7331,需设置 LONGMEMORY_API_KEY;从源码运行需先 corepack enable 并用 pnpm 安装构建。
LongMemory
CaviraOSSApache-2.0活跃维护给 LLM 应用提供本地持久化记忆存储,让 Claude Desktop、Copilot、Codex 等智能体跨会话记住上下文,不用把数据传到云端。
Local persistent memory store for LLM applications including claude desktop, github copilot, codex, antigravity, etc.
npm install longmemory
npm install --global longmemory && longmemory initREADME 未说明显存或 GPU 要求;库模式无需外部服务或数据库,服务端默认监听 127.0.0.1:7331,可用 Docker 部署。
本地优先的持久化记忆引擎,让 LLM 应用和 Agent 不再失忆
给 LLM 应用提供本地持久化记忆存储,让 Claude Desktop、Copilot、Codex 等智能体跨会话记住上下文,不用把数据传到云端。
核心能力
- 用 SQLite 持久化不可变节点、边与时序历史
- 支持 strict、historical、associative、world_grounded 四种召回模式
- 区分记录时间与有效时间,保留被取代的历史真相
- 按项目、租户、用户、角色等范围强制治理与 ACL
- 通过 MCP 暴露 13 个受治理工具接入各类 Agent 宿主
容易踩的坑
- v1.3.0Beta v1.3.0最新正式版2025-12-20 · 2025-12-20 16:45 UTC
Changelog
api simplification
- python sdk: simplified to zero-config
Memory()api matching javascriptfrom openmemory.client import Memory→mem = Memory()- works out of the box with sensible defaults (in-memory sqlite, fast tier, synthetic embeddings)
- optional configuration via environment variables or constructor
- breaking change: moved from
OpenMemoryclass toMemoryclass
benchmark suite rewrite
- implemented comprehensive benchmark suite in
temp/benchmarks/- typescript-based using
tsxfor execution - supports longmemeval dataset evaluation
- multi-backend comparison (openmemory, mem0, zep, supermemory)
- typescript-based using
- created
src/main.tsconsolidated benchmark runner- environment validation
- backend instantiation checks
- sequential benchmark execution with detailed logging
✨ features
core improvements
-
Memory.wipe(): added database wipe functionality for testingclear_allimplementation indb.tsfor postgres and sqlite- clears memories, vectors, waypoints, and users tables
- useful for benchmark isolation and test cleanup
-
environment variable overrides:
OM_OLLAMA_MODEL: override ollama embedding modelOM_OPENAI_MODEL: override openai embedding modelOM_VEC_DIM: configure vector dimension (critical for embedding compatibility)OM_DB_PATH: sqlite database path (supports:memory:)
vector store enhancements
- added comprehensive logging to
PostgresVectorStore- logs vector storage operations with id, sector, dimension
- logs search operations with sector and result count
- aids in debugging retrieval issues
🐛 bug fixes
-
embedding configuration:
- fixed
models.tsto respectOM_OLLAMA_MODELenvironment variable - resolved dimension mismatch issues (768 vs 1536) for embeddinggemma
- ensured
OM_TIER=deepuses semantic embeddings (not synthetic fallback)
- fixed
-
benchmark data isolation:
- implemented proper database reset between benchmark runs
- fixed simhash collision issues causing cross-user contamination
- added
resetUser()functionality callingMemory.wipe()
-
configuration loading:
- fixed dotenv timing issues in benchmark suite
- ensured environment variables load before openmemory-js initialization
- corrected dataset path resolution (
longmemeval_s.json)
📚 documentation
-
comprehensive readme updates:
- root
README.md: language-agnostic, showcases both python & javascript sdks packages/openmemory-js/README.md: complete api reference, mcp integration, examplespackages/openmemory-py/README.md: zero-config usage, all embedding providers
- root
-
api documentation:
- environment variables with descriptions
- cognitive sectors explanation
- performance tiers breakdown
- embedding provider configurations
🔧 internal improvements
- type safety: added lint error handling in benchmark adapters
- code organization: separated generator, judge, and backend interfaces
- debug tooling: created dimension check script (
check_dim.ts) - logging standardization: consistent
[Component]prefix pattern
⚠️ breaking changes
- python sdk now uses
from openmemory.client import Memoryinstead offrom openmemory import OpenMemory Memory()constructor signature changed to accept optional parameters (was required)- benchmark suite moved to typescript (was python)
- Feature - Add Frontend Docker Image by @dflor003 in https://github.com/CaviraOSS/OpenMemory/pull/100
New Contributors
- @dflor003 made their first contribution in https://github.com/CaviraOSS/OpenMemory/pull/100
Full Changelog: https://github.com/CaviraOSS/OpenMemory/compare/v1.2.3...v1.3.0
- python sdk: simplified to zero-config
- v1.2.32025-12-12 · 2025-12-12 15:32 UTC
查看更新说明
1.2.3 - 2025-12-14
Added
- Temporal Filtering: Enables precise time-based memory retrieval
- Added
startTimeandendTimefilters toquerymethod across Backend, JS SDK, and Python SDK. - Allows filtering memories by creation time range.
- Fully integrated into
hsg_querylogic.
- Added
Fixed
- JavaScript SDK Types: Fixed
IngestURLResultimport error andv.vproperty access bug inVectorStoreintegration. - Python SDK Filtering: Fixed missing implementation of
user_idand temporal filters inhsg_queryloop.
What's Changed
- fix: Add PATCH to CORS allowed methods by @aziham in https://github.com/CaviraOSS/OpenMemory/pull/93
New Contributors
- @aziham made their first contribution in https://github.com/CaviraOSS/OpenMemory/pull/93
Full Changelog: https://github.com/CaviraOSS/OpenMemory/compare/v1.2.2...v1.2.3
- Temporal Filtering: Enables precise time-based memory retrieval
- v1.2.22025-12-06 · 2025-12-06 14:42 UTC
查看更新说明
Fixed
-
MCP Server Path Resolution: Fixed ENOENT error in stdio mode (Claude Desktop)
- Enforced absolute path resolution for SQLite database
- Ensures correct data directory creation regardless of working directory
- Critical fix for local desktop client integration
-
VectorStore Refactor: Fixed build regressions in backend
- Migrated deprecated
qvector operations toVectorStoreinterface - Fixed
users.ts,memory.ts,graph.ts,mcp.ts, anddecay.ts - Removed partial SQL updates in favor of unified vector store methods
- Migrated deprecated
Added
- Valkey VectorStore Enhancements: Improved compatibility and performance
- Refined vector storage implementation for Valkey backend
- Optimized vector retrieval and storage operations
Changed
-
IDE Extension:
- Updates to Dashboard UI (
DashboardPanel.ts) and extension activation logic (extension.ts) - Configuration and dependency updates
- Updates to Dashboard UI (
-
Python SDK:
- Refinements to embedding logic (
embed.py) - Project configuration updates in
pyproject.toml
- Refinements to embedding logic (
-
Backend Maintenance:
- Dockerfile updates for improved containerization
- Updates to CLI tool (
bin/opm.js)
New Contributors
- @ajitam made their first contribution in https://github.com/CaviraOSS/OpenMemory/pull/69
- @fparrav made their first contribution in https://github.com/CaviraOSS/OpenMemory/pull/80
- @DAESA24 made their first contribution in https://github.com/CaviraOSS/OpenMemory/pull/83
- @oantoshchenko made their first contribution in https://github.com/CaviraOSS/OpenMemory/pull/84
- @therexone made their first contribution in https://github.com/CaviraOSS/OpenMemory/pull/85
Full Changelog: https://github.com/CaviraOSS/OpenMemory/compare/1.2.1...v1.2.2
-
- 1.2.1V1.2.12025-11-23 · 2025-11-23 12:20 UTC
查看更新说明
1.2.1 - Standalone Sdk
Added
-
Python SDK (
sdk-py/): SDK Overhaul, it can now perform as a standalone version of OpenMemory- Full feature parity with Backend
- Local-first architecture with SQLite backend
- Multi-sector memory (episodic, semantic, procedural, emotional, reflective)
- All embedding providers: synthetic, OpenAI, Gemini, Ollama, AWS
- Advanced features: decay, compression, reflection
- Comprehensive test suite (
sdk-py/tests/test_sdk_py.py)
-
JavaScript SDK Enhancements (
sdk-js/): SDK Overhaul, it can now perform as a standalone version of OpenMemory- Full feature parity with Backend
- Local-first architecture with SQLite backend
- Multi-sector memory (episodic, semantic, procedural, emotional, reflective)
- All embedding providers: synthetic, OpenAI, Gemini, Ollama, AWS
- Advanced features: decay, compression, reflection
-
Examples: Complete rewrite of both JS and Python examples
examples/js-sdk/basic-usage.js- CRUD operationsexamples/js-sdk/advanced-features.js- Decay, compression, reflectionexamples/js-sdk/brain-sectors.js- Multi-sector demonstrationexamples/py-sdk/basic_usage.py- Python CRUD operationsexamples/py-sdk/advanced_features.py- Advanced configurationexamples/py-sdk/brain_sectors.py- Sector demonstrationexamples/py-sdk/performance_benchmark.py- Performance testing
-
Tests: Comprehensive test suites for both SDKs
tests/js-sdk/js-sdk.test.js- Full SDK validationtests/py-sdk/test-sdk.py- Python SDK validation- Tests cover: initialisation, CRUD, sectors, advanced features
-
Architecture Documentation
- Mermaid diagram in main README showing complete data flow
- Covers all 5 cognitive sectors
- Shows embedding engine, storage layer, and recall engine
- Includes temporal knowledge graph integration
- Node.js script to regenerate diagrams
-
- 1.2.02025-11-05 · 2025-11-05 16:42 UTC
查看更新说明
What's New
- Web UI to control OpenMemory
- HYBRID Tier Performance Mode
- Memory Compression Engine
What's Changed
- Decay system
- perf(vector): Optimized the aggregateVectors function by @DKB0512 in https://github.com/CaviraOSS/OpenMemory/pull/26
- perf(embedding): Optimize embedWithLocal by @DKB0512 in https://github.com/CaviraOSS/OpenMemory/pull/29
- perf(chunk): Optimized the combineChunk function by @DKB0512 in https://github.com/CaviraOSS/OpenMemory/pull/27
- Add permissions for content read access by @recabasic in https://github.com/CaviraOSS/OpenMemory/pull/31
New Contributors
- @recabasic made their first contribution in https://github.com/CaviraOSS/OpenMemory/pull/31
Full Changelog: https://github.com/CaviraOSS/OpenMemory/compare/1.1.1...1.2.0
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
LongMemory
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.
- 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:
- Split text into chunks.
- Embed the chunks.
- 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, open tasks, failures, code facts, matched Skills, conflicts, and governed asset loadouts under one token budget.
8. CLI
longmemory init
longmemory tui
longmemory status --memories 20 --json
longmemory ingest "Remember the rollback procedure" --type procedure
longmemory recall "What is the rollback procedure?" --mode associative
longmemory memory list --limit 50
longmemory project context "prepare the next release"
longmemory maintenance decay --all
longmemory maintenance reinforce <memory-id>
longmemory skill match "run the release checklist" --agent reviewer
longmemory asset loadout "prepare the release" --agent reviewer --framework codex
longmemory code impact createMemory
longmemory detect
longmemory session discover --from claude-code
longmemory port --from claude-code --to longmemory --all
longmemory session wiki --from gemini-cli --all --name "Project knowledge"
longmemory serve --mcp-http
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.
9. Dashboard and VS Code
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 start
The 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:package
The generated package is apps/vscode-extension/longmemory-vscode-0.2.0.vsix.
10. Architecture
graph TB
INPUT[Events, documents, sessions] --> INGEST[Immutable ingest pipeline]
INGEST --> GRAPH[(Hydrograph)]
GRAPH --> STRICT[Strict and historical recall]
GRAPH --> ASSOC[Associative recall]
GRAPH --> GROUND[World-grounded recall]
GRAPH --> PROJECT[Project memory and governed assets]
GRAPH --> SQLITE[(SQLite)]
STRICT --> CONTEXT[Explainable bounded context]
ASSOC --> CONTEXT
GROUND --> CONTEXT
PROJECT --> MCP[MCP tools, resources, prompts]
CONTEXT --> API[Library, CLI, HTTP]
MCP --> AGENTS[Agents, IDEs, automation]
API --> UI[Dashboard and VS Code]
Read ARCHITECTURE.md and docs/architecture.md for subsystem details.
11. Deployment Options
| 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.
12. Benchmarks
pnpm bench
pnpm bench:ci
pnpm bench:full
The 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.
13. Migration
Import supported SQLite, JSON, or JSONL memory:
longmemory migrate \
--from ./legacy.db \
--to ./longmemory.db \
--report ./migration-report.json
Import coding-agent conversations as governed Chat Memory:
longmemory port --from codex --to longmemory --all
See MIGRATION.md and docs/migration.md.
Legacy package migration:
npm uninstall openmemory-js && npm install longmemory
pip uninstall openmemory-py && pip install longmemory-sdk
openmemory-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.
14. Release and Operations
corepack enable
pnpm install --frozen-lockfile
pnpm release:check
pnpm pack
pnpm extension:package
release: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 dashboard
15. Security
LongMemory is local-first, but network deployment still requires explicit controls:
- Protect API and MCP routes with
LONGMEMORY_API_KEY. - Restrict allowed origins and terminate TLS at the edge.
- Keep connector and embedding credentials outside repository files.
- Treat recalled content as untrusted evidence, not authorization.
- Preserve server-bound user, project, agent, and framework identity.
Report vulnerabilities privately as described in SECURITY.md.
16. Contributing
Issues and pull requests are welcome. Read CONTRIBUTING.md, GOVERNANCE.md, and CODE_OF_CONDUCT.md before contributing.
- Issues: https://github.com/CaviraOSS/LongMemory/issues
- Discussions: https://github.com/CaviraOSS/LongMemory/discussions
- Changelog: CHANGELOG.md
17. License
LongMemory is licensed under the Apache License 2.0. The separately published n8n community node uses MIT as required by n8n's strict package validator.