Skip to main content

Persistent memory for Claude — Ebbinghaus forgetting curve, semantic deduplication, MCP-native

Project description

YourMemory

Persistent memory for AI agents — built on the science of how humans remember.

PyPI PyPI Downloads License: CC BY-NC 4.0 LoCoMo Recall@5 LongMemEval Recall@5 Docker Build


The Problem

Every session, your AI assistant starts from zero. It asks the same questions, forgets your preferences, re-learns your stack. There is no memory between conversations.

YourMemory fixes that. It gives AI agents a persistent memory layer that works the way human memory does — important things stick, forgotten things fade, outdated facts get replaced automatically. One command to install, zero infrastructure required. Memory starts working the moment you add it to your AI client.


How Well Does It Work?

LoCoMo-10 — 1,534 QA pairs across 10 multi-session conversations

System Recall@5 95% CI
YourMemory (BM25 + vector + graph + decay) 59% 56–61%
Zep Cloud 28% 26–30%

2× better recall than Zep Cloud on the same benchmark.

The 59% result used all-mpnet-base-v2. The current default model (multi-qa-mpnet-base-dot-v1) scores 55% on LoCoMo session-summary retrieval — see BENCHMARKS.md for details.

LongMemEval-S — 500 questions, ~53 sessions each

System Recall-all@5 nDCG@5
YourMemory (full stack · multi-qa-mpnet-base-dot-v1) 85% 87%

Full methodology in BENCHMARKS.md. Writeup: I built memory decay for AI agents using the Ebbinghaus forgetting curve.


Quick Start

Supports Python 3.11–3.14. No Docker, no database setup, no external services.

Step 1 — Install

pip install yourmemory

Step 2 — Get your config path

yourmemory-path

Prints your full executable path and a ready-to-paste config block. Copy it.

Step 3 — Wire into your AI client

Claude Code

Add to ~/.claude/settings.json:

{
  "mcpServers": {
    "yourmemory": {
      "command": "yourmemory"
    }
  }
}

Reload (Cmd+Shift+PDeveloper: Reload Window).

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "yourmemory": {
      "command": "yourmemory"
    }
  }
}

Restart Claude Desktop.

Cline (VS Code)

VS Code doesn't inherit your shell PATH. Run yourmemory-path first to get the full executable path.

In Cline → MCP ServersEdit MCP Settings:

{
  "mcpServers": {
    "yourmemory": {
      "command": "/full/path/to/yourmemory",
      "args": [],
      "env": { "YOURMEMORY_USER": "your_name" }
    }
  }
}

Restart Cline after saving.

Cursor

Add to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "yourmemory": {
      "command": "/full/path/to/yourmemory",
      "args": [],
      "env": { "YOURMEMORY_USER": "your_name" }
    }
  }
}
Windsurf / OpenCode / any MCP client

YourMemory is a standard stdio MCP server. Use the full path from yourmemory-path if the client doesn't inherit shell PATH.

{
  "mcpServers": {
    "yourmemory": {
      "command": "/full/path/to/yourmemory",
      "env": { "YOURMEMORY_USER": "your_name" }
    }
  }
}

First start is automatic. On the first run, YourMemory initialises your database, downloads the language model, and injects memory workflow instructions into your AI client config — no manual setup needed.

Step 4 — Start remembering

That's it. On the first MCP start, YourMemory automatically:

  • Initialises your local database at ~/.yourmemory/memories.duckdb
  • Downloads the spaCy language model in the background
  • Injects the memory workflow rules into your AI client

Your AI now recalls what it learned in previous sessions, without you telling it to.


Memory Dashboard

Every YourMemory instance ships with a built-in browser UI. When the MCP server is running, open:

http://localhost:3033/ui

Browse your memories by agent, filter by category, sort by strength, and see which memories are fading.

What you'll see
  • Strength bars — how close each memory is to being pruned
  • Agent tabs — switch between All / User / per-agent views
  • Category badges — fact · strategy · assumption · failure
  • Stats — total, strong (≥ 50%), fading (5–50%), near prune (< 10%)

MCP Tools

Three tools, called by your AI automatically.

Tool When What it does
recall_memory(query, current_path?) Start of every task Surfaces relevant memories ranked by similarity × strength; boosts spatially matched memories
store_memory(content, importance, context_paths?) After learning something new Embeds and stores with biological decay; tags optional file/dir paths for spatial recall
update_memory(id, new_content) When a memory is outdated Re-embeds and replaces; logs old content to audit trail
# Store with spatial context
store_memory("Sachit prefers tabs over spaces in Python", importance=0.9, category="fact",
             context_paths=["/projects/backend"])

# Next session — spatial boost applied when working in that path:
recall_memory("Python formatting", current_path="/projects/backend")
# → {"content": "Sachit prefers tabs over spaces in Python", "strength": 0.87, "score": 0.81}

Categories control how fast memories fade

Category Survives without recall Use case
strategy ~38 days Successful patterns
fact ~24 days Preferences, identity
assumption ~19 days Inferred context
failure ~11 days Errors, environment-specific issues

How It Works

Ebbinghaus Forgetting Curve

Memory strength decays exponentially — importance and recall frequency slow that decay:

effective_λ  = base_λ × (1 - importance × 0.8)
strength     = clamp(importance × e^(−effective_λ × active_days) × (1 + recall_count × 0.2), 0, 1)
hybrid_score = 0.4 × bm25_norm + 0.6 × cosine_similarity

active_days counts only days the user was active — vacations don't cause memory loss. Decay is used for pruning only, not ranking. Memories below strength 0.05 are pruned automatically every 24 hours.

Session wrap-up scoring: recalled memory IDs are tracked per session and get a recall_count boost when the session goes idle (30 min default). Set YOURMEMORY_SESSION_IDLE to change the window.

Recall throttling: identical (user, query) pairs are cached to avoid redundant retrieval within a configurable window. Set YOURMEMORY_RECALL_COOLDOWN (seconds, default 0 = off).

Hybrid Retrieval: Vector + BM25 + Graph

Retrieval runs in two rounds to surface related context that vocabulary-based search misses:

Round 1 — Hybrid search: cosine similarity + BM25 keyword scoring, returns top-k above threshold.

Round 2 — Graph expansion: BFS traversal from Round 1 seeds surfaces memories that share context but not vocabulary — connected via semantic edges (cosine similarity ≥ 0.4).

recall("Python backend")
  Round 1 → [1] Python/MongoDB    (sim=0.61)
             [2] DuckDB/spaCy     (sim=0.19)
  Round 2 → [5] Docker/Kubernetes (sim=0.29 — below cut-off, surfaced via graph)

Chain-aware pruning: A decayed memory is kept alive if any graph neighbour is above the prune threshold. Related memories age together.


Multi-Agent Memory

Multiple agents can share the same YourMemory instance — each with isolated private memories and controlled access to shared context.

from src.services.api_keys import register_agent

result = register_agent(
    agent_id="coding-agent",
    user_id="sachit",
    can_read=["shared", "private"],
    can_write=["shared", "private"],
)
# → result["api_key"]  — ym_xxxx, shown once only

Pass api_key to any MCP call to authenticate as an agent:

store_memory(content="Staging uses self-signed cert — skip SSL verify",
             importance=0.7, category="failure",
             api_key="ym_xxxx", visibility="private")

recall_memory(query="staging SSL", api_key="ym_xxxx")
# → returns shared memories + this agent's private memories
# → other agents see shared only

Stack

Component Role
DuckDB Default vector DB — zero setup, native cosine similarity
NetworkX Default graph backend — persists at ~/.yourmemory/graph.pkl
sentence-transformers Local embeddings (multi-qa-mpnet-base-dot-v1, 768 dims)
spaCy Local NLP for deduplication and SVO triple extraction
APScheduler Automatic 24h decay job
PostgreSQL + pgvector Optional — for teams or large datasets
Neo4j Optional graph backend — pip install 'yourmemory[neo4j]'
PostgreSQL setup (optional)
pip install yourmemory[postgres]

Create a .env file:

DATABASE_URL=postgresql://YOUR_USER@localhost:5432/yourmemory

macOS

brew install postgresql@16 pgvector && brew services start postgresql@16
createdb yourmemory

Ubuntu / Debian

sudo apt install postgresql postgresql-contrib postgresql-16-pgvector
createdb yourmemory

Architecture

Claude / Cline / Cursor / Any MCP client
    │
    ├── recall_memory(query, current_path?, api_key?)
    │       └── throttle check (YOURMEMORY_RECALL_COOLDOWN)
    │               embed → vector similarity (Round 1)
    │               → graph BFS expansion  (Round 2)
    │               → score = sim × strength → top-k
    │               → spatial boost (+0.08) if current_path matches context_paths
    │               → session tracking → recall_count bump on session end
    │
    ├── store_memory(content, importance, category?, context_paths?, visibility?, api_key?)
    │       └── question? → reject
    │               contradiction check → update if conflict
    │               embed() → INSERT → index_memory() → graph node + edges
    │               record_activity(user_id) → active days log
    │
    └── update_memory(id, new_content, importance)
            └── log old content → memory_history (audit trail)
                    embed(new_content) → UPDATE → refresh graph node

  Vector DB (Round 1)             Graph DB (Round 2)
  DuckDB (default)                NetworkX (default)
    memories.duckdb                 graph.pkl
    ├── embedding FLOAT[768]        ├── nodes: memory_id, strength
    ├── importance FLOAT            └── edges: sim × verb_weight ≥ 0.4
    ├── recall_count INTEGER
    ├── context_paths JSON        Neo4j (opt-in)
    ├── visibility VARCHAR          └── bolt://localhost:7687
    ├── agent_id VARCHAR
    user_activity (active days log)
    memory_history (supersession audit)

Contributing

PRs are welcome. See CONTRIBUTORS.md for the people who have already improved YourMemory.


Dataset Reference

Benchmarks use the LoCoMo dataset by Snap Research.

Maharana et al. (2024). LoCoMo: Long Context Multimodal Benchmark for Dialogue. Snap Research.


License

Copyright 2026 Sachit Misra — Licensed under CC-BY-NC-4.0.

Free for: personal use, education, academic research, open-source projects.
Not permitted: commercial use without a separate written agreement.

Commercial licensing: mishrasachit1@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yourmemory-1.4.13.tar.gz (71.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yourmemory-1.4.13-py3-none-any.whl (75.5 kB view details)

Uploaded Python 3

File details

Details for the file yourmemory-1.4.13.tar.gz.

File metadata

  • Download URL: yourmemory-1.4.13.tar.gz
  • Upload date:
  • Size: 71.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for yourmemory-1.4.13.tar.gz
Algorithm Hash digest
SHA256 813829f8e3b0925343c78a7135b635431525e765e1554ff16247c3260162a90a
MD5 c7c77a7534c5160f54f018920d4b3fda
BLAKE2b-256 bd14560920c0d987d495f0efffa736931caf225c439a65c452db0d86f8c6616c

See more details on using hashes here.

File details

Details for the file yourmemory-1.4.13-py3-none-any.whl.

File metadata

  • Download URL: yourmemory-1.4.13-py3-none-any.whl
  • Upload date:
  • Size: 75.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for yourmemory-1.4.13-py3-none-any.whl
Algorithm Hash digest
SHA256 0fc81d261a3fe2196e86a3c4a1e2c6177a02d490bdb1549fba2172b6fe3668d4
MD5 4afcacc6762ded09b56d34338a6ef858
BLAKE2b-256 243552510dcfd4f871ce148353d6aa45c7f0e707f26705a898a3fbb01a416f85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page