io.github.sachitrafa/cognitive-ai-memory

编码与调试

by sachitrafa

为 Claude 提供基于艾宾浩斯遗忘曲线的持久记忆,记忆会随时间衰减并在回忆时增强。

什么是 io.github.sachitrafa/cognitive-ai-memory

为 Claude 提供基于艾宾浩斯遗忘曲线的持久记忆,记忆会随时间衰减并在回忆时增强。

README

<!-- mcp-name: io.github.sachitrafa/yourmemory --> <div align="center"> <img src="logo.svg.png" alt="YourMemory" width="110" /><br> <h1>YourMemory</h1>

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

PyPI PyPI Downloads Python License: CC BY-NC 4.0 GitHub Stars GitHub Issues Last Commit Docker Build

LoCoMo Recall@5 LongMemEval Recall@5 HotpotQA BOTH@5 oosmetrics

</div>

What Is YourMemory?

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 with a one-command install that plugs into Claude, Cursor, Cline, Windsurf, or any MCP client. It gives your AI a persistent memory layer modelled on human cognition:

  • Things that matter stick — importance score controls how quickly a memory decays
  • Outdated facts get replaced — subject-aware deduplication merges or supersedes memories automatically
  • Related context surfaces together — entity graph links memories that share people, places, or concepts
  • Old memories fade naturally — Ebbinghaus forgetting curve prunes stale context every 24 hours

Zero infrastructure required. SQLite by default, Postgres for teams.


Table of Contents


Benchmarks

Three external datasets, all scripts open source and reproducible. Full methodology in BENCHMARKS.md.

LongMemEval-S — 500 questions, ~53 distractor sessions each

The hardest standard benchmark for long-term memory systems. Each question is backed by ~53 conversation sessions; the model must retrieve the right one(s) from the haystack.

MetricScore
Recall@5 (any gold session in top-5)89.4%
Recall-all@5 (all gold sessions in top-5)84.8%
nDCG@5 (ranking quality)87.4%

By question type (Recall@5):

Question TypeRecall@5n
single-session-assistant98.2%56
knowledge-update96.2%78
multi-session95.5%133
single-session-preference90.0%30
temporal-reasoning84.2%133
single-session-user72.9%70

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

Conversations spanning weeks to months. Every system ingests the same session summaries in the same order.

SystemRecall@595% CI
YourMemory (BM25 + vector + graph + decay)59%56–61%
Zep Cloud28%26–30%
Supermemory31%*28–33%
Mem018%*16–20%

2× better recall than Zep Cloud across all 10 samples. * Supermemory and Mem0 exhausted free-tier quotas mid-benchmark; scores computed over full 1,534 pairs using 0 for unfinished samples.

HotpotQA — 200 multi-hop questions requiring two facts from different articles

SystemBOTH_FOUND@5
YourMemory (vector + BM25 + entity graph)71.5%
YourMemory (no entity edges)59.5%

Entity graph edges add +12 pp — they traverse from Fact 1 to Fact 2 even when Fact 2 has low embedding similarity to the query.

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.

1 — Install

bash
pip install yourmemory
yourmemory-setup

yourmemory-setup auto-detects your AI client (Claude Code, Claude Desktop, Cursor, Cline, Windsurf, OpenCode), writes the MCP config, and initialises your database. That's it for most users.

2 — Wire into your AI client manually (if needed)

<details> <summary><strong>Claude Code</strong></summary>

Add to ~/.claude/settings.json:

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

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

</details> <details> <summary><strong>Claude Desktop</strong></summary>

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

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

Restart Claude Desktop.

</details> <details> <summary><strong>Cline (VS Code)</strong></summary>

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

In Cline → MCP ServersEdit MCP Settings:

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

Restart Cline after saving.

</details> <details> <summary><strong>Cursor</strong></summary>

Add to ~/.cursor/mcp.json:

json
{
  "mcpServers": {
    "yourmemory": {
      "command": "/full/path/to/yourmemory",
      "args": [],
      "env": { "YOURMEMORY_USER": "your_name" }
    }
  }
}
</details> <details> <summary><strong>Windsurf / OpenCode / any MCP client</strong></summary>

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

json
{
  "mcpServers": {
    "yourmemory": {
      "command": "/full/path/to/yourmemory",
      "env": { "YOURMEMORY_USER": "your_name" }
    }
  }
}
</details>

First start is automatic. On the first run, YourMemory initialises your database at ~/.yourmemory/memories.duckdb, downloads the spaCy language model in the background, and injects memory workflow rules into your AI client config. Nothing to configure manually.


Memory Dashboard

Two built-in browser UIs — no extra setup, start automatically with the MCP server.

Memory Browser — http://localhost:3033/ui

A full read/write view of everything stored in memory.

What you seeDetails
Stats barTotal · Strong ≥50% · Fading 5–50% · Near prune <10%
Agent tabsAll / User / per-agent views
Memory cardsContent · strength bar · category · recall count · last accessed
FiltersCategory (fact / strategy / assumption / failure) · Sort by strength, recency, recall

Pass ?user=<id> to pre-load a specific user: http://localhost:3033/ui?user=sachit

Graph Visualiser — http://localhost:3033/graph

An interactive force-directed map of how memories connect.

code
http://localhost:3033/graph?memoryId=42&userId=sachit&depth=2
  • Root memory as a larger cyan node; neighbours color-coded by category
  • Edge thickness = connection strength
  • Click any node for full content; drag, zoom, reposition freely

Ask Without Calling the API

The only memory system that can answer questions without making any LLM API call.

bash
yourmemory ask "what database does this project use"
# → YourMemory uses DuckDB locally and Postgres in production.

yourmemory ask "what port does the dashboard run on"
# → 3033

yourmemory ask "how do I fix a kubernetes deployment"
# → Not enough memory context to answer without Claude.

When memory is strong enough, it answers instantly — zero tokens, zero cloud cost, zero latency. When it isn't, it declines cleanly rather than hallucinating.

QueryMem0 / Zep / LangMemYourMemory
"What port does the server run on?"Full LLM API callInstant, $0
"What database does this project use?"Full LLM API callInstant, $0
"How do I fix a k8s deployment?"Full LLM API callDeclines → Claude
PrivacyQuery sent to cloudNever leaves your machine

MCP Tools

Three tools, called by your AI automatically.

ToolWhen your AI calls itWhat it does
recall_memory(query, current_path?)Start of every taskSurfaces memories ranked by similarity × decay strength; spatial boost for path-matched memories
store_memory(content, importance, category?, context_paths?)After learning something newEmbeds, deduplicates, stores with decay; tags optional file/dir paths
update_memory(id, new_content, importance)When a stored fact is outdatedRe-embeds and replaces; logs old content to audit trail
python
# 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 fires when working in that directory
recall_memory("Python formatting", current_path="/projects/backend")
# → {"content": "Sachit prefers tabs over spaces in Python", "strength": 0.87}

Memory categories control decay rate

CategoryHalf-lifeBest for
strategy~38 daysPatterns that worked, architectural decisions
fact~24 daysPreferences, identity, stable knowledge
assumption~19 daysInferred context, uncertain beliefs
failure~11 daysErrors, wrong approaches, environment-specific issues

How It Works

Ebbinghaus Forgetting Curve

Memory strength decays exponentially. Importance and recall frequency slow that decay:

code
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. Memories below strength 0.05 are pruned automatically every 24 hours.

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

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

Hybrid Retrieval: Vector + BM25 + Entity Graph

Retrieval runs in two rounds:

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

Round 2 — Graph expansion: BFS traversal from Round 1 seeds surfaces memories that share context but not vocabulary — connected via semantic or entity edges.

code
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 shared entity "backend")

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

Subject-Aware Deduplication

Before storing, YourMemory checks whether the new memory is about the same entity as the nearest existing one:

code
"Sachit uses DuckDB"      vs  "YourMemory uses DuckDB"
 subject: Sachit               subject: YourMemory
 → different entities → stored separately ✓

"YourMemory uses DuckDB"  vs  "YourMemory stores data in DuckDB"
 subject: YourMemory           subject: YourMemory
 → same entity → merged ✓

Subject comparison embeds the first two tokens of each sentence — no hardcoded word lists, generalises to any language.


Multi-Agent Memory

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

python
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)
python
# Agent stores a private failure memory
store_memory(
    "Staging uses self-signed cert — skip SSL verify",
    importance=0.7, category="failure",
    api_key="ym_xxxx", visibility="private"
)

# Recalls shared + its own private memories; other agents see shared only
recall_memory("staging SSL", api_key="ym_xxxx")

Stack

ComponentRole
DuckDBDefault vector DB — zero setup, native cosine similarity
NetworkXDefault graph backend — persists at ~/.yourmemory/graph.pkl
sentence-transformersLocal embeddings (multi-qa-mpnet-base-dot-v1, 768 dims)
spaCyLocal NLP for deduplication and entity extraction
APSchedulerAutomatic 24h decay and pruning job
PostgreSQL + pgvectorOptional — for teams or large datasets
Neo4jOptional graph backend — pip install 'yourmemory[neo4j]'
<details> <summary><strong>PostgreSQL setup (optional)</strong></summary>
bash
pip install yourmemory[postgres]

Create a .env file:

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

macOS

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

Ubuntu / Debian

bash
sudo apt install postgresql postgresql-contrib postgresql-16-pgvector
createdb yourmemory
</details>

Architecture

code
Claude / Cline / Cursor / Any MCP client
    │
    ├── recall_memory(query, current_path?, api_key?)
    │       └── throttle check → embed → hybrid search (Round 1)
    │               → graph BFS expansion (Round 2)
    │               → score = sim × strength
    │               → spatial boost (+0.08) if current_path matches context_paths
    │               → temporal boost (+0.25) if query has time window expression
    │               → session tracking → recall_count bump on session end
    │
    ├── store_memory(content, importance, category?, context_paths?, api_key?)
    │       └── question? → reject
    │               subject-aware dedup → same entity? merge/reinforce : new
    │               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)
    ├── created_at TIMESTAMP         └── bolt://localhost:7687
    ├── visibility VARCHAR
    ├── agent_id VARCHAR
    user_activity  (active days log)
    memory_history (supersession audit)

Contributing

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


Dataset References

  • LoCoMo — Maharana et al. (2024). LoCoMo: Long Context Multimodal Benchmark for Dialogue. Snap Research.
  • LongMemEval — Wu et al. (2024). LongMemEval: Benchmarking Chat Assistants on Long-Term Interactive Memory.
  • HotpotQA — Yang et al. (2018). HotpotQA: A Dataset for Diverse, Explainable Multi-hop Question Answering.

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

常见问题

io.github.sachitrafa/cognitive-ai-memory 是什么?

为 Claude 提供基于艾宾浩斯遗忘曲线的持久记忆,记忆会随时间衰减并在回忆时增强。

相关 Skills

前端设计

by anthropics

Universal
热门

面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。

想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。

编码与调试
未扫描148.2k

网页应用测试

by anthropics

Universal
热门

用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。

借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。

编码与调试
未扫描148.2k

网页构建器

by anthropics

Universal
热门

面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。

在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。

编码与调试
未扫描148.2k

相关 MCP Server

GitHub

编辑精选

by GitHub

热门

GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。

这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。

编码与调试
86.6k

by Context7

热门

Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。

它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。

编码与调试
57.0k

by tldraw

热门

tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。

这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。

编码与调试
47.7k

评论