TrueMemory

buildingjoshbetterAGPL-3.0活跃维护

给 AI 编程助手加一层本地长期记忆,自动捕获对话并自动召回,全部存在单个 SQLite 文件里,不依赖云端,兼容 Claude Code、Cursor 等 CLI 工具。

The memory your AI should have had from the start. Automatic capture, automatic recall, 100% local. One SQLite file, zero cloud. Works with Claude Code, Claude CLI, Cursor, Codex CLI, Gemini CLI.

v0.7.6.2发布于 2026-06-11 20:33 UTC386star +1 / 7 天52fork同步于 2026-11-10 18:01 UTC

怎么上手

由 README 提炼,执行前请确认
curl -LsSf https://raw.githubusercontent.com/buildingjoshbetter/TrueMemory/main/install.sh | sh
pip install truememory
硬件要求按 README 说明

Edge 档纯 CPU 可跑,Base/Pro 需 4GB+ 内存;Pro 另需 LLM API key。安装时下载约 1.5GB 模型。README 未说明 GPU 型号要求。

纯 CPU 可运行
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

给 AI 编码工具加本地长期记忆,自动捕获并召回对话,数据只存一个 SQLite 文件

给 AI 编程助手加一层本地长期记忆,自动捕获对话并自动召回,全部存在单个 SQLite 文件里,不依赖云端,兼容 Claude Code、Cursor 等 CLI 工具。

核心能力

  • 用生命周期钩子自动捕获对话并注入下次会话
  • 六层检索管线加 reranker,支持多轮 search_deep
  • 自动解决矛盾、更新过期事实并整合记忆
  • directive 标记的常驻指令每次会话自动加载
  • 提供 11 个 MCP 工具与 Python Memory API

容易踩的坑

安装脚本会下载约 1.5GB 模型,需等 3-5 分钟;装完要完全退出并重开 AI 工具才生效;Pro 档的 HyDE 检索需要自备 LLM API key;匿名遥测默认开启,需设 TRUEMEMORY_TELEMETRY=off 关闭

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.7.6.2
  1. v0.7.6.2v0.7.6.2 — BLAST OFF v3 hardening最新正式版2026-06-11 · 2026-06-11 20:33 UTC

    v0.7.6.2 — BLAST OFF v3 hardening

    An autonomous adversarial hardening + security + performance + reliability pass. 16 fixes (all 7 P1

    • 9 P2) across PRs #698–713, including the 3 incomplete v2 fixes now fully closed (#638→#698, #649→#708, #653→#699). No API or behavior changes for normal use.

    Security (P1)

    • Prompt-injection / exfil hardening — recalled memory + directive text is escaped/sanitized before injection so stored content can't forge <truememory-*> / <system…> framing (#698); Stop/drain hooks guard the transcript path against out-of-tree reads (#699).
    • Least privilege — DB + -wal/-shm + the TrueMemory root are chmod'd 0600/0700 (#704).
    • forget() completeness — purges all derived/aggregate tables, not just the row (#701).

    Reliability (P1/P2)

    • Engine auto-reconnect on a dead SQLite handle (#700).
    • Crash-safe cosine migration via a commit-coupled done sentinel (#702).
    • Near-duplicate dedup keeps facts differing only by a number (#703).
    • build_summaries now uses the SAVEPOINT transaction wrapper — completes the #649 txn-hygiene fix that was the v2 live-lock root cause (#708).
    • Atomic writes everywhere: 20 adapter config sites + recall cache (fixes a fixed-tmp interleave race) + Online-Backup snapshot for pre-migration backups (#707).
    • Per-session debounce on the per-exchange store (#709); extracted-marker pruning runs independent of the stale-session scan (#710, the 54K-marker unbounded-growth bug).

    Performance

    • Empty-consolidation recall no longer double-scans FTS — a measured ~185 ms/recall saved at 3k rows (PERF-01 #705); recall p50 168 ms → 47 ms at 1k.
    • Recall/dedup-only hot paths skip the cross-encoder (#706).

    Supply chain & hygiene

    • Every GitHub Action SHA-pinned, incl. the OIDC publish job (#711).
    • hdbscan declared as an optional extra; untrusted text control-char-stripped before logging (#712).
    • Docs accuracy (11 MCP tools, live metadata field), sdist excludes tests/, test offline-env centralized in conftest (#713).

    Validation

    1941 tests pass; perf A/B confirms the recall improvement; real-embedding sanity OK. Ratings vs the post-v2 baseline: operational 8 → 9.0/10, security 6 → 8.5/10.

    Known residual: torch CVE-2025-3000 (core dependency, no upstream fix published; pre-existing, not introduced here).

  2. v0.7.6.1v0.7.6.1 — BLAST OFF v2 hardening release2026-06-11 · 2026-06-11 13:33 UTC
    查看更新说明

    Hardening release: 25 fixes across the search pipeline, dedup/encoding gate, model server, hooks, directives, vector search, config, and platform compatibility (#630-#654).

    Highlights:

    • Vector tables now use cosine distance correctly (were L2); Base/Pro embeddings normalized at write time.
    • Score-space contract: stop comparing relative retrieval scores to absolute cosine thresholds.
    • Fixed a search crash on tied scores and dropped contradiction supplements.
    • Memory Intensity per-exchange store path restored (was dead code).
    • Directive injection hardening, recall-cache correctness, model-server lifecycle, DB-corruption UX, Windows compatibility, config validation, and a shared env-var parser.
    • CI: the real-vector regression gate now actually runs online.

    Full validation green across the CI matrix (ubuntu 3.10-3.13, macOS, Windows).

  3. v0.7.5.0v0.7.5.0 — Deterministic Memory Triggering2026-06-08 · 2026-06-08 11:56 UTC
    查看更新说明

    Deterministic Memory Triggering

    TrueMemory tools are now guaranteed to be eagerly loaded in Claude Code, regardless of how many other MCP servers are installed. No more "coin flip" reliability.

    What changed

    • alwaysLoad annotations — The 4 critical MCP tools (truememory_search, truememory_search_deep, truememory_store, truememory_stats) now carry meta={"anthropic/alwaysLoad": True}, ensuring Claude Code loads their schemas eagerly even with 100+ tools from other servers.
    • Installer patches alwaysLoad: true — truememory-ingest setup now sets alwaysLoad: true on the truememory MCP server entry in settings.json.
    • Removed ToolSearch workaround — The CRITICAL — LOADING TRUEMEMORY TOOLS instructions are no longer needed and have been removed.

    Cross-platform CI hardening

    • Fixed Windows CI: temp dir cleanup, os.kill liveness check, file permissions, USERPROFILE env var
    • Fixed macOS CI: removed flaky concurrent SQLite test
    • Fixed Python 3.10 CI: tomllib skip
    • Fixed file handle leaks in model_client.py and session_start.py
    • Atomic config writes in tier_switch/manager.py
    • Refactored engine.py god class into 3 modules

    Upgrade

    pip install --upgrade truememory
    # Then re-run setup to get alwaysLoad patched in:
    truememory-ingest setup
    

    Full changelog: https://github.com/buildingjoshbetter/TrueMemory/blob/main/CHANGELOG.md

  4. v0.7.1.32026-05-23 · 2026-05-23 04:36 UTC
    查看更新说明

    Fix

    • fix: centralize tier resolution for Base/Pro users (#383)
      • Created resolve_tier() as the canonical tier resolver (env var → config.json → "edge" fallback)
      • Replaced 3 instances of os.environ.get("TRUEMEMORY_EMBED_MODEL", "edge") in engine.py that ignored the user's configured tier
      • Previous fixes (v0.7.1.1, v0.7.1.2) addressed vector_search.py and mcp_server.py but missed engine.py
      • Validated: 6 local tests pass, 5/5 APPROVE from OpenRouter multi-model review (GPT-4.1, Gemini 2.5 Pro, Claude Sonnet 4, Qwen3 235B, Llama 4 Maverick)
  5. v0.7.1.22026-05-23 · 2026-05-23 03:42 UTC
    查看更新说明

    Fix

    • fix(vector_search): read config.json as fallback when env var is unset
      • v0.7.1.1's mcp_server.py import reorder was insufficient — Python runs __init__.py before any mcp_server.py code, so the env var could never be set in time.
      • vector_search.py now reads ~/.truememory/config.json directly when TRUEMEMORY_EMBED_MODEL is not in the environment, ensuring Base/Pro users get the correct embedding model regardless of import order.
      • Supersedes v0.7.1.1.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Why TrueMemory

    It finds signal in the noise. Your AI sees thousands of messages. TrueMemory figures out which ones actually matter and throws away the rest. No manual tagging, no prompt engineering. It just knows.

    It gets sharper over time. It's not a static database. It's a living memory that grows with you. It resolves contradictions when you change your mind, updates stale facts, and consolidates what it knows. The longer you use it, the better it gets.

    It works without you thinking about it. TrueMemory automatically captures memories from your conversations and automatically injects the right ones into your next session. You never have to store or search for anything manually. It just happens.

    It's 100% local. One SQLite file on your machine. Your memories never leave your device. No cloud, no API keys needed. Your data is yours. (Anonymous usage telemetry is the only exception — never memory content — and one env var turns it off. Details.)

    Without TrueMemory: "What framework are we using?" Asked for the 12th time this week. Your agent starts every session with amnesia. It doesn't know your name, your stack, or anything you told it yesterday.

    With TrueMemory: Your agent already knows you use FastAPI, prefer Pydantic v2, and that your auth middleware lives in src/auth/. It remembers your corrections, your preferences, and your decisions. Across every session, forever.


    How TrueMemory Compares

    SystemLoCoMoLongMemEvalLocal-firstAuto-captureLicense
    TrueMemory Pro93.0%92.0%✅✅AGPL-3.0
    TrueMemory Base92.0%84.1%✅✅AGPL-3.0
    Mem061.4%—Partial❌Apache-2.0
    Supermemory65.4%—❌❌Cloud API
    MemOS75.8%—✅❌Apache-2.0
    ReadAgent79.5%—❌❌Research

    All benchmarks independently reproducible. Scripts included in benchmarks/.


    Quick Start

    For Claude Code / Claude CLI / Cursor / Codex CLI / Gemini CLI

    curl -LsSf https://raw.githubusercontent.com/buildingjoshbetter/TrueMemory/main/install.sh | sh
    

    Installs everything in an isolated environment. Downloads ~1.5GB of AI models. No data leaves your machine. No sudo required.

    1. Open a terminal: Mac: Cmd + Space, type Terminal. Linux: Ctrl + Alt + T. Windows: open PowerShell.
    2. Paste the command above and press Enter.
    3. Wait 3-5 minutes for models to download.
    4. Quit your AI tool completely and reopen it (Mac: Cmd+Q).
    5. Type "Set up TrueMemory" and pick a tier.

    Windows (PowerShell):

    irm https://raw.githubusercontent.com/buildingjoshbetter/TrueMemory/main/install.ps1 | iex
    

    That's it. TrueMemory remembers your conversations automatically from here. Need help? Join our Discord.

    If TrueMemory saves you time, a ⭐ helps other devs find it.

    For developers (Python library)

    pip install truememory
    
    from truememory import Memory
    
    m = Memory()
    m.add("Prefers dark mode and TypeScript", user_id="alex")
    print(m.search("preferences", user_id="alex"))
    

    Tiers

    Same architecture, three tiers. All included in a single install. Switch anytime by saying "switch to Pro" or "switch to Base."

    EdgeBasePro
    LoCoMo89.6%92.0%93.0%
    LongMemEval——92.0%
    BEAM-1M——76.6% (SOTA)
    Embedding model8 MB lightweight600 MB high-accuracy600 MB high-accuracy
    Reranker22M params149M params149M params
    HyDE search——✅ (requires LLM API key)
    Runs onAny machine, CPU only4 GB+ RAM4 GB+ RAM + API key

    Edge works everywhere. Base is the strongest fully-offline tier. Pro adds AI-powered query expansion for the highest scores.


    Benchmarks

    Tested across three major benchmarks with all systems sharing the same answer model (GPT-4.1-mini), judge (GPT-4o-mini, 3x majority vote), and scoring pipeline.

    BenchmarkWhat it testsTrueMemory Pro
    LoCoMo1,540 questions across 10 conversations93.0%
    LongMemEval500 multi-session questions92.0%
    BEAM-1M700 questions at 1M+ tokens76.6% (SOTA)
    BEAM-10M200 questions at 10M tokens65.0%

    Reproduce any result yourself

    Every benchmark script is self-contained and runs on Modal.

    All benchmarks use the same eval pipeline. Nothing is hidden. Full details: LoCoMo | LongMemEval | BEAM


    Works With

    Lifecycle hooks capture conversations automatically. No manual work needed. Your memories stay local in a single SQLite file.


    Python API

    from truememory import Memory
    
    m = Memory()
    
    m.add("Prefers dark mode and TypeScript", user_id="alex")
    m.add("Works at Anthropic as a senior engineer", user_id="alex")
    m.add("Always sign commits with GPG", directive=True)  # directives auto-load every session
    
    results = m.search("What are Alex's preferences?", user_id="alex")
    results = m.search_deep("career history?", user_id="alex")  # multi-round, higher accuracy
    
    MethodDescription
    m.add(content, user_id)Store a memory (directive=True for standing instructions that auto-load at the start of every session)
    m.search(query, user_id)Search (6-layer pipeline + reranker)
    m.search_deep(query, user_id)Multi-round agentic search
    m.get(id) / m.get_all(user_id)Retrieve memories
    m.update(id, content) / m.delete(id)Modify or remove
    m.stats()System statistics

    Full API reference →


    Docs

    Getting StartedInstall to first memory
    Python API ReferenceFull Memory class reference
    MCP Tool ReferenceAll 11 MCP tools
    CLI Referencetruememory-mcp and truememory-ingest
    Environment VariablesAll TRUEMEMORY_* config options
    Architecture Deep Dive6-layer retrieval pipeline, encoding gate
    Tier Selection GuideEdge vs Base vs Pro
    DebuggingLogs, traces, common issues

    FAQ

    Everything lives locally in ~/.truememory/memories.db. Edge and Base tiers make zero external calls. Pro sends only your search query text to an LLM for query expansion. Your memories are never transmitted.

    No. The installer uses uv to manage a sandboxed Python 3.12. Your system Python is never touched.

    Context windows are expensive, slow, and empty at the start of every session. TrueMemory gives instant recall for zero tokens of context, in under 200ms.

    Anonymous usage telemetry (tool calls, session counts, platform info) is on by default. We never track memory content, queries, file paths, or API keys. Opt out: export TRUEMEMORY_TELEMETRY=off


    Get Started in 60 Seconds

    For Claude Code, Claude CLI, Cursor, Codex CLI, or Gemini CLI:

    curl -LsSf https://raw.githubusercontent.com/buildingjoshbetter/TrueMemory/main/install.sh | sh
    

    Using it as a Python library instead? pip install truememory

    Questions? Join our Discord or open a Discussion. If TrueMemory saves you time, give us a ⭐


    Thanks to Our Contributors


    Research

    TrueMemory is backed by a research paper (arXiv preprint) on retrieval-centered agent memory.

    Storage Is Not Memory: A Retrieval-Centered Architecture for Agent Recall (arXiv 2605.04897)

    @article{sauronlabs2026storage,
      title   = {Storage Is Not Memory: A Retrieval-Centered Architecture for Agent Recall},
      author  = {Sauron Labs},
      journal = {arXiv preprint arXiv:2605.04897},
      year    = {2026},
      url     = {https://arxiv.org/abs/2605.04897}
    }
    

    Community

    If TrueMemory saves you time, give us a ⭐


    Translations

    Read this in: 简体中文 · हिन्दी · Español · Français · العربية · বাংলা · Português · Русский · 日本語 · 한국어 · Deutsch · Bahasa Indonesia · Tiếng Việt · Türkçe · Italiano · ไทย · Polski · Українська · Nederlands


    License

    AGPL-3.0. Free for personal and research use. Commercial use requires a separate license. Contact [email protected].