Memory that learns from forgetting. A 1-dependency Python library that gives any LLM persistent memory with auto-evolving knowledge graphs, temporal reasoning, and fleet-wide failure learning.
Project description
lore-memory
The git init for AI memory.
Teach your AI once. It remembers forever. Works with every coding agent.
Why
Your AI forgets everything between sessions. You repeat yourself. It makes the same mistakes. lore-memory fixes that.
- One memory, every agent — drop-in MCP server works with Claude Code, Cursor, Windsurf, Codex, and any MCP-compatible tool
- Error recipes — fix a bug once, never fix it again. Pattern-matches stderr automatically with regex + BM25 fallback
- Memory immune system — SHA-256 provenance hashes + trust scoring (user=1.0, agent=0.8, mined=0.6, fleet=0.5) prevent hallucinated facts from poisoning your memory
- Zero cost, fully local — single SQLite file, WAL mode, FTS5 full-text search. No cloud. No API keys. 1 dependency (
pyyaml)
Install
pip install lore-memory
Quick Start (60 seconds)
# Store a memory
lore-memory remember "We use PostgreSQL, never MySQL"
# Search memories
lore-memory recall "which database do we use"
# Show statistics
lore-memory stats
# Manage identity context (injected into every session)
lore-memory identity set name=Miles role=CTO project=lore
lore-memory identity get
MCP Server (Claude Code, Cursor, Windsurf)
Add to your Claude Code / Cursor MCP settings:
{
"mcpServers": {
"lore-memory": {
"command": "python3",
"args": ["-m", "lore_memory.mcp.server"]
}
}
}
Or set a custom database path:
{
"mcpServers": {
"lore-memory": {
"command": "python3",
"args": ["-m", "lore_memory.mcp.server"],
"env": {
"LORE_MEMORY_DB": "/path/to/your/memory.db"
}
}
}
}
6 MCP Tools
| Tool | Description |
|---|---|
lore_teach |
Store a convention, rule, or preference. Source defaults to user (trust 1.0). Auto-generates provenance hash. |
lore_remember |
Store any memory with explicit type and source. Returns memory ID + trust score + provenance hash. |
lore_recall |
FTS5 BM25 search with trust threshold, time window, and type filter. Touches accessed memories. |
lore_fix |
Store an error recipe: maps an error signature (string or regex) to solution steps. |
lore_match_procedure |
Find the best fix for a given error. Regex match first, FTS5 fallback. Returns solution steps. |
lore_stats |
Full system statistics: memory counts by type, trust level breakdown, darwin patterns, WAL entries. |
Example MCP Usage
# In Claude Code (after adding MCP server):
lore_teach("Always use f-strings, never .format() or %")
lore_fix("ModuleNotFoundError: No module named", ["pip install -r requirements.txt", "check venv is activated"])
lore_recall("string formatting convention")
lore_match_procedure("ModuleNotFoundError: No module named 'requests'")
Python API
from lore_memory import LoreMemory
with LoreMemory() as mem:
# Store memories
mem.remember("User prefers dark mode")
mem.remember("Always use async/await", memory_type="fact")
# Search
results = mem.recall("theme preference")
for r in results:
print(r["content"])
# Identity context
mem.identity.set({"name": "Miles", "role": "CTO"})
# Statistics
print(mem.stats())
How It Works
Your input
│
▼
┌─────────────┐ SHA-256 hash ┌──────────────────┐
│ lore_teach │ ──────────────────► │ SQLite (WAL) │
│ lore_fix │ trust scoring │ memories table │
│ lore_remember │ darwin_journal │
└─────────────┘ │ darwin_patterns │
│ identity │
└────────┬─────────┘
│
FTS5 BM25 index
│
┌────────────────────────────────────────▼──────────────┐
│ lore_recall → ranked results by relevance │
│ lore_match_procedure → regex match → FTS5 fallback │
└───────────────────────────────────────────────────────┘
Storage: Single ~/.lore-memory/default.db SQLite file. WAL mode for concurrent reads. FTS5 virtual table for BM25 full-text ranking.
Trust scoring: Every memory carries a trust_score (0.0–1.0) and SHA-256 provenance_hash based on content + timestamp. Recall filters by min_trust (default 0.5) to suppress low-confidence memories from polluting results.
Error recipes: lore_fix stores both a darwin_pattern (for fast regex matching) and a memories entry (for FTS5 fallback). lore_match_procedure tries regex first, falls back to BM25 search automatically.
Decay: Every memory has a decay_score (default 1.0). Memories accessed via lore_recall get their access_count incremented. Low-decay memories can be filtered out of search results.
Configuration
Create ~/.lore-memory.yml to override defaults:
db_path: ~/.lore-memory/default.db
layers:
search:
top_k: 10
temporal:
decay_halflife_days: 30
darwin:
enabled: true
pattern_threshold: 3
Config search order: explicit path → ./.lore-memory.yml → ~/.lore-memory.yml → built-in defaults.
vs Others
| Feature | lore-memory | claude-mem | mem0 | MemPalace |
|---|---|---|---|---|
| Works with ALL agents | Yes | Claude only | Claude/GPT | Claude only |
| Error recipes + pattern matching | Yes | No | No | No |
| Provenance hashes + trust scoring | Yes | No | No | No |
| Fully local, no cloud | Yes | Yes | No ($249/mo graph tier) | No |
| MCP server included | Yes | No | No | No |
| Python API | Yes | No | Yes | No |
| Dependencies | 1 (pyyaml) |
— | Many | — |
| Free forever | Yes | Yes | Limited | Limited |
Ecosystem
| Package | What it does |
|---|---|
| lore | CLI agent reliability audits — scan agents for failure patterns |
| lore-review | Security scanner — OWASP/CVE scanning for Python projects |
| lore-memory | Persistent memory for AI agents (this package) |
| phalanx | Circuit breakers, DLQs, and compliance primitives for agent fleets |
License
MIT — see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lore_memory-0.2.0.tar.gz.
File metadata
- Download URL: lore_memory-0.2.0.tar.gz
- Upload date:
- Size: 67.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40fe9495d4b27626d138539f5b0039c3dbe961430112a53b410f4bce492c13c6
|
|
| MD5 |
a1637ee720b7bafe840505b5255f0b9f
|
|
| BLAKE2b-256 |
2f66f5dd6c8910e1dfec16f530e92ed09b9d21d50ccf02b0d8835504447b0467
|
File details
Details for the file lore_memory-0.2.0-py3-none-any.whl.
File metadata
- Download URL: lore_memory-0.2.0-py3-none-any.whl
- Upload date:
- Size: 49.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e5b2eaa6b0eea443a1d680992f250ff0c90220f46e3022b2f1b2166e75720fd
|
|
| MD5 |
803cedc87dd2b57d0a6adeaf84713a9c
|
|
| BLAKE2b-256 |
4bf9960958c0fcbb9c22b3090e6e1f2977ce282690953500b32e9ae21891ff76
|