{"slug": "show-hn-memledger-ai-agent-memory-you-can-trust", "title": "Show HN: MemLedger – AI agent memory you can trust", "summary": "MemLedger, an open-source AI agent memory framework, provides transparent provenance for every stored fact, enabling users to trace the origin, extraction model, and approval history of memories. It uses a deterministic filter to reduce LLM costs, supports memory regeneration with improved models, and quarantines new facts until confirmed across sessions to prevent poisoning. The system runs locally on a single SQLite file with no vendor lock-in.", "body_md": "\n\n```\n /$$      /$$                         /$$                       /$$                              \n| $$$    /$$$                        | $$                      | $$                              \n| $$$$  /$$$$  /$$$$$$  /$$$$$$/$$$$ | $$        /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$   /$$$$$$ \n| $$ $$/$$ $$ /$$__  $$| $$_  $$_  $$| $$       /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$\n| $$  $$$| $$| $$$$$$$$| $$ \\ $$ \\ $$| $$      | $$$$$$$$| $$  | $$| $$  \\ $$| $$$$$$$$| $$  \\__/\n| $$\\  $ | $$| $$_____/| $$ | $$ | $$| $$      | $$_____/| $$  | $$| $$  | $$| $$_____/| $$      \n| $$ \\/  | $$|  $$$$$$$| $$ | $$ | $$| $$$$$$$$|  $$$$$$$|  $$$$$$$|  $$$$$$$|  $$$$$$$| $$      \n|__/     |__/ \\_______/|__/ |__/ |__/|________/ \\_______/ \\_______/ \\____  $$ \\_______/|__/      \n                                                                    /$$  \\ $$                    \n                                                                   |  $$$$$$/                    \n                                                                    \\______/\n```\n\n**AI agent memory you can trust — because it can tell you why.**\n\nEvery memory framework solves the forgetting problem: agents now remember things across sessions. But they create a new problem: memory becomes a black box. The agent \"knows\" things, but you can't tell where a fact came from, why it was kept, or why a user's preference from three weeks ago just vanished. When the memory fails (and it will) you can't debug it. You can only delete everything and start over.\n\n**MemLedger is memory with the black box wide open.** Every fact your agent\nholds has a full chain of provenance. A single command, `memledger why`\n\n,\nshows you the exact sentence a memory was born from, which model extracted\nit, when it was promoted to permanent knowledge, and who approved it.\n\nIt's like a bank statement for memory: you don't just see the balance, you see every single transaction that produced it.\n\n``` bash\n$ memledger why tu_01J9ZKM3\ntu_01J9ZKM3  (instinct, active)  \"The user prefers Python as their language\"\n └─ promoted   2026-07-02  cause: impact 5.5 ≥ 5 across 4 sessions, approved by dev\n    └─ extracted  2026-06-28  model: qwen3:4b  prompt: extract@v1  confidence: 0.95\n       └─ observed  se_88 turn 3   \"please, always Python — I don't read Go\"\n       └─ observed  se_91 turn 12  \"again: Python examples only\"\n```\n\nUse `memledger why <id> --json`\n\nto print the raw provenance payload instead.\n\n-\n**Pay for intelligence only when it matters.** A zero-cost, deterministic filter decides which conversational turns are worth LLM extraction. \"Ok, thanks!\" will never cost you a token; \"the deploy failed because of the env vars\" will. Most chat traffic is phatic noise; MemLedger recognizes and skips it, drastically cutting memory costs. -\n**Memory improves with models, instead of aging with them.** Other frameworks freeze memories the moment they're written. If today's model extracts poorly, that error is permanent. MemLedger always keeps the raw source, so when a better model comes out, you run`regenerate`\n\nand your agent's entire memory is re-built,*better*, from the original history. No competitor can do this. -\n**Anti-poisoning by design.** New facts are quarantined until confirmed across multiple sessions. Nothing becomes permanent knowledge without your approval (`memledger review`\n\n). And if a bad fact gets through, provenance leads you to the source, and a cascading delete removes it and everything derived from it. -\n**Truly yours.** It's a single SQLite file on your machine. You choose the model — even a small, free, local one via Ollama. No mandatory servers, no vendor lock-in, MIT licensed. It runs on a laptop.\n\nThree memory layers mimicking human cognition, all built on an append-only event ledger. The ledger — not the projections — is the source of truth.\n\n```\n   ┌──────────────────┐   ┌──────────────────┐   ┌──────────────────┐\n   │     Instinct     │   │     Episodic     │   │      Working     │\n   │ (Core facts)     │   │ (Long-term)      │   │ (Current session)│\n   └────────┬─────────┘   └────────┬─────────┘   └────────┬─────────┘\n            │                      │                      │\n            └──────────────────┐   │   ┌──────────────────┘\n                               ▼   ▼   ▼\n                  ┌─────────────────────────────┐\n                  │   Event Ledger (SQLite)     │\n                  │ (Append-only, auditable)    │\n                  └─────────────────────────────┘\n```\n\n**Instinct:** Core facts injected into every context. Seeded by you, or promoted automatically when a fact proves itself across sessions.**Episodic:** Long-term tuples`(subject, relation, value)`\n\nwith confidence, impact scores, and TTL, extracted by an LLM at checkpoint.**Working:** The current session's turn-by-turn buffer.\n\nEvery extraction, promotion, merge, and deletion is an event with an explicit cause. An LLM does the smart work, but every decision is logged, reproducible, and reversible.\n\n```\npip install .\n# or: pip install -e \".[dev]\"\n# add [local] for CPU embeddings: pip install \".[local]\"\nmemledger init\npython\nfrom memledger import Ledger, Policy\n\nledger = Ledger(\"./memory.db\", policy=Policy.default(),\n                memory_model=\"openai-compat:http://localhost:11434/v1|qwen3:4b\")\n                # ...or any OpenAI-compatible / Anthropic endpoint\n\nsession = ledger.session(user_id=\"me\")\n\nwhile (msg := input(\"> \")):\n    memories = session.recall(msg, k=5)\n    ctx = session.build_context(instinct=True, episodic=memories, working=\"tail\")\n    reply = your_llm(system=ctx.system, messages=ctx.messages, user=msg)\n    session.observe(user=msg, assistant=reply)\n    print(reply)\n\nreport = session.checkpoint()        # extract → reflect → promote\nprint(report.tokens_saved_in_context)\n```\n\nRuns on a laptop CPU with a local model, or with any cloud endpoint. Storage is a single SQLite file. No server, no vendor lock-in.\n\nFor the practical repo guide in English, including installation,\nthe full CLI reference, and the main operational workflows, see\n[docs/usage.md](/riktar/memledger/blob/main/docs/usage.md).\n\nWhy not just use another memory framework?\n\n**vs. LLM-based memory (Mem0, Zep, etc.):** They give you a memory that works until it doesn't. We give you one you can query, replay, and fix when it breaks.**vs. Deterministic approaches:** They sacrifice semantic understanding for reproducibility. We keep both: rules where you need guarantees, LLMs where you need intelligence, and a full audit trail for everything.\n\n**The one-liner: Others make your agent remember. MemLedger lets you know why it remembers.**\n\n`memledger why <id>`\n\n· `review`\n\n· `replay --at <ts> --cached`\n\n·\n`rebuild`\n\n· `regenerate --model <m>`\n\n· `delete <id> --cascade`\n\n· `stats`\n\nFor options, examples, and workflow explanations, see\n[docs/usage.md](/riktar/memledger/blob/main/docs/usage.md).\n\nEverything lives in `memory.policy.yaml`\n\n— promotion thresholds, the\nimpact formula, retention, retrieval and quarantine settings. It's hashed,\nand the hash is recorded in every event, so config changes never rewrite\nhistory. See the file for line-by-line docs.\n\nMemLedger ships a benchmark harness for two long-term memory benchmarks:\n\n**LoCoMo**(in progress) — question answering over very long multi-session dialogs, with evidence dialog ids for retrieval scoring.\n\n**0.1 \"Ego\"** — single agent, single file, single writer. Stable spec\n(`SPEC.md`\n\n), Python SDK, CLI, local + cloud model backends.\n\nPlanned: TypeScript SDK reading the same ledger format · shared multi-agent memory (next profile) · hosted sync and audit dashboard.\n\nMIT. The `SPEC.md`\n\nledger format is open: conforming clients in any\nlanguage are welcome — `memledger rebuild`\n\nis the conformance test.", "url": "https://wpnews.pro/news/show-hn-memledger-ai-agent-memory-you-can-trust", "canonical_source": "https://github.com/riktar/memledger", "published_at": "2026-07-09 16:24:19+00:00", "updated_at": "2026-07-09 16:37:11.308009+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "ai-infrastructure", "ai-ethics", "developer-tools"], "entities": ["MemLedger", "Ollama", "Qwen"], "alternates": {"html": "https://wpnews.pro/news/show-hn-memledger-ai-agent-memory-you-can-trust", "markdown": "https://wpnews.pro/news/show-hn-memledger-ai-agent-memory-you-can-trust.md", "text": "https://wpnews.pro/news/show-hn-memledger-ai-agent-memory-you-can-trust.txt", "jsonld": "https://wpnews.pro/news/show-hn-memledger-ai-agent-memory-you-can-trust.jsonld"}}