wanyi
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@wanyi Recall my past mistakes about stop-loss rules"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
WanYi Memory Core 万忆中枢
Never-forgetting full-quantity memory system — Event-sourced long-term memory for AI agents: process memory, mistake books, experience crystallization, confidence-based decision blocking, counterfactual branches, cross-domain analogy, trajectory replay, proactive partner, semantic vector retrieval, reranker, memory graph, time decay and metacognitive knowledge-gaps. Ships as a local-first MCP server with 23 tools. Your data never leaves your machine.
🎬 Live Demo: Interactive demo page · source code
docs/demo.html
Why this is different
Most memory systems store your data in the cloud, need a heavy dependency stack, or only do keyword search. wanyimem is local-first, single-file SQLite, and installs with one dependency (numpy).
wanyimem | typical memory server | |
Data | never leaves your machine (zero telemetry) | cloud / SaaS |
Infra | SQLite single file, no separate vector DB | Qdrant / Neo4j / Postgres |
Defaults | shadows the agent, blocks high-risk actions, opens counterfactual branches | stores & retrieves |
Resources | runs on 2-core / 2GB | heavier |
Evolves | zero-participation (learns from your mistakes automatically) | manual "remember this" |
23 MCP tools, open source (MIT), Python 3.10+, pip install wanyimem.
Related MCP server: localmem-mcp
Why
LLM agents forget. Every chat window is amnesia: preferences, lessons, and hard-won experience evaporate when the session ends.
WanYi Memory Core is a local-first, full-quantity, self-evolving memory system:
Event sourcing — an append-only WAL is the single source of truth. Nothing is ever deleted; decay only affects retrieval ranking.
Semantic recall — hybrid retrieval: BM25 keywords + local Chinese embedding (BAAI/bge-small-zh-v1.5) + reranker (BAAI/bge-reranker-base) + knowledge-graph expansion + explicit time decay. Vector search is hybrid itself: exact cosine below
ANN_MIN_COUNT, and asqlite-vecANN pre-filter + exact re-rank above it — so it stays fast at scale without sacrificing recall quality.Metacognition — when recall is weak, the system admits it and records a knowledge-gap instead of hallucinating an answer.
Decision guardrails — high-risk actions (all-in, revenge-trading, force-push, rm -rf) trigger confidence-based blocking with counterfactual branches: you see what would have happened if you had listened.
Zero-participation evolution — no need to say "remember this"; the system decides what to store, consolidates overnight, and surfaces weekly trajectory reviews.
Install
pip install wanyimem # core
pip install "wanyimem[all]" # + vector/reranker models + sqlite-vec ANN (use [ann] for ANN only)Requires Python 3.10+. Models (embedding ~95MB, reranker ~1.1GB) are downloaded on first use from HuggingFace; set HF_ENDPOINT=https://hf-mirror.com if you are in mainland China.
Before the PyPI release lands, you can also install directly from GitHub (identical code):
pip install "git+https://github.com/17861102832/wanyimem.git"
CLI & Automation
Beyond the MCP server, wanyimem ships two console commands after pip install wanyimem:
wanyi-export --db memory.db --out memory.md # readable, diff-able Markdown mirror of all memory (read-only)
wanyi-auto --db memory.db # one AutoMoat pass: honest counterfactual auto-settlement + consolidation + analog patrol
wanyi-auto --db memory.db --loop 3600 # periodic scheduler (daemon background; off by default)
wanyi-exportrenders the event-sourced store into a human-readable, version-controllable Markdown mirror (grouped by Tao/Method/Technique, plus mistakes / experiences / knowledge-gaps / counterfactual branches / cross-domain patterns).wanyi-autoautomates the guardrails: it honestly settles overdue counterfactual branches (marking themexpiredrather than fabricating a winner), runs sleep + deep consolidation, and surfaces the cross-domain analog patterns most worth recalling.
Quick Start (MCP)
Add to your mcp.json (Claude Desktop, Cursor, Trae, etc.):
{
"mcpServers": {
"wanyi": {
"command": "python",
"args": ["-m", "wanyi.memory_core"],
"env": {
"WANYI_STORE_DIR": "C:/path/to/your/memory"
}
}
}
}Env keys are "Chinese-first, ASCII-fallback": the new
WANYI_STORE_DIR(recommended, more portable) and the legacy万忆中枢_STORE_DIRboth work. Barepythondepends on PATH and may fail; prefer an absolute interpreter path, orpip install wanyimemthen use"command": "wanyi".
Then any agent can call the 23 tools, e.g.:
万忆记录见闻 → "2026年5月基金大跌时我死扛不止损,亏了18%才割肉。"
万忆召回记忆 → query "认赔离场到底对不对" # semantic match even with zero shared keywords
万忆置信度决策检查 → "我要全仓梭哈" # BLOCK if confidence is low, with historical mistakesQuick Start (Library)
from wanyi import WanYiCore
engine = WanYiCore()
engine.tool_record_memory(
content="止损纪律:亏损超过8%必须无条件卖出",
layer="法", mem_type="principle",
)
resp = engine.tool_recall_memory("认赔离场到底对不对", limit=5)
for m in resp["memories"]:
print(m["content"], m.get("_rerank_score"))Features
Area | Capability |
Storage | SQLite + append-only event WAL; Tao/Method/Technique three-layer half-lives |
Retrieval | Keyword BM25 + vector (bge-small-zh) + reranker (bge-reranker-base) + graph expansion + time-decay fields |
Metacognition | knowledge-gap auto-record, |
Guardrails | confidence-based decision blocking, counterfactual branches with auto-settlement, cross-domain analogy bridging |
Proactivity | daily brief on LOAD, due-branch reminders, weekly trajectory replay, risk-keyword alert |
Growth | mistake book, experience crystallization, overnight consolidation, evolution queries |
Privacy | fully local, zero telemetry, no cloud dependency |
Public benchmark (LongMemEval) — session-level retrieval, full results in benchmark/RESULTS.md. Core (BM25 + graph, no models) reaches Recall@5 = 0.960 / MRR = 0.907 on s_cleaned (with ~40 distractor sessions). Reproduce via python benchmark/longmemeval_run.py.
Benchmark — reproducible mini LongMemEval (14 keyword-mismatched cross-session fact queries, run via python benchmark/recall_benchmark.py):
Version | Recall@5 | MRR |
Core (keyword BM25 + knowledge-graph, no models) | 1.000 (14/14) | 0.857 |
Full (bge-small-zh vector + bge-reranker-base rerank) | 1.000 (14/14) | 0.857 |
Every query is intentionally phrased with different keywords than its answer (e.g. 本地数据库怎么提高并发写 → WAL模式, 记忆系统最怕什么 → 事件溯源), so 14/14 reflects genuine semantic recall, not string matching. The knowledge-graph channel (active in the core, model-free) already lifts BM25 to parity here; the vector + reranker path shows its edge on larger-scale semantic expansion ("pip install wanyimem[all]" downloads the models).
Docs
Contributing
See CONTRIBUTING.md. Report vulnerabilities privately via SECURITY.md.
License
MIT © 2026 Zhao Xikun
Available Tools
23 tools万忆主动搭档A
护城河#5「主动搭档」:从被动工具升级为主动搭档,不等用户开口自动出击。brief今日简报(待结算分支+到期提醒+高命中跨域模式+决策健康提示,LOAD钩子自动调用)、proactive_check主动体检(到期/超期/重复踩坑)、weekly_review每周轨迹回放复盘(stats+route+review合成总结)、alert风险关键词扫描(文本中出现梭哈/追涨/全仓/删库/强推等风险词立即告警并建议过拦截)。
Inputs: days, text, action.
万忆加载进度C
加载历史存档 — 按checkpoint_id、task_name或全量查询
Inputs: task_name, checkpoint_id.
万忆反事实之镜A
护城河#2「反事实之镜」:在关键决策点开平行分支(事实路径 vs 反事实路径),到期自动结算对比。每次BLOCK/CAUTION拦截时自动开立;支持手动open开分支、settle记录实际结果并自动判定verdict(fact_won/counter_won/neutral)、list_open查待结算、list_settled查已结算、auto_check_due自动检查到期。counter_won时自动沉淀入错题本并强化置信度拦截。
Inputs: tags, action, lesson, branch_id, +9 more.
万忆召回记忆C
四通道混合检索(v5.0):BM25关键词 + 倒排索引 + 知识图谱 + 语义向量(v5.1),reranker精排(v5.2)+ 时序衰减显性化(v5.4)+ 知识空白元认知(弱召回自动记录gap)
Inputs: query (required), layer, limit, space, +3 more.
万忆园艺师B
园艺师后台(KektorDB式):深巩固(矛盾检测+冗余检测+洞见提炼+技能结晶+每日思考档案)/ 仅写每日日志
Inputs: action.
万忆图谱搜索A
知识图谱扩展检索 — 从实体节点出发多跳遍历,发现语义关联记忆(v5.3记忆写入时自动建边:semantic-similar/same-category)
Inputs: query (required), depth, limit.
万忆存档进度A
存档任务进度 — 支持跨会话冷续传,保存任务名、阶段、进度百分比、完整状态
Inputs: phase (required), state (required), task_name (required), progress_pct (required).
万忆导入档案A
更新用户偏好档案(交易风格/风险偏好/写作风格/个人信息等),同时存入道级钉住记忆
Inputs: data (required).
万忆更新交易锚点C
更新交易策略锚点 — 分板块管理你的核心交易逻辑与参数
Inputs: data (required), section (required).
万忆查询进化A
最近进化记录:谁变了、为什么变、置信度变化 — 进化的可观测性,任何聊天框都能查到真实发生在文件系统上的进化
Inputs: limit.
万忆睡眠巩固A
睡眠巩固周期:记忆衰减 + 重要度增强 + 相似合并 + 低价值归档,定期运行
Inputs: no named parameters.
万忆知识压缩A
对指定层级进行全量压缩 — 保留摘要+元数据,原始内容归档,释放存储空间
Inputs: layer.
万忆知识空白A
v5.1元认知「知道自己不知道什么」:召回太弱时自动记录知识空白,系统主动承认库存薄弱。list列出待补充空白(按被查中次数排序,越常查越该补)、close标记已补充(gap_id+note)、stats统计(开放数/已关闭数/最薄弱领域TOP)。结合语义向量检索,让万忆在检索到强结果时自信、搜不到时坦承,而不是瞎编。
Inputs: note, limit, action, gap_id.
万忆经验库C
经验库(ExpeL式):成功路径沉淀的可复用模式,跨任务迁移复用
Inputs: limit, task_name.
万忆置信度决策检查A
护城河#1「拦截之眼」:对即将执行的高风险决策做认知置信度检查。支持:check(决策拦截,自动识别梭哈/追涨/不止损/删库/强推等风险动作,置信度不足时BLOCK并亮历史错题)/validate(对某判断投支持票)/challenge(投反对票)/review(FSRS复习)/get(查置信度)/rank(置信度排名)/needs_review(待复习清单)。在做重仓、追涨、删库、强推等高风险动作前必调用。BLOCK/CAUTION时自动联动护城河#2开立反事实分支。
Inputs: action, reason, signal, target_id, +4 more.
万忆触发LOAD钩子A
HOOK-LOAD:会话启动时自动注入记忆 — 道级钉住记忆、法级高频记忆、断点续传检查
Inputs: no named parameters.
万忆触发STORE钩子A
HOOK-STORE / HOOK-REFLECT:会话结束时归档 + 反思 — 提炼决策、模式、技能、复盘
Inputs: mode, skills, memories, patterns, +4 more.
万忆记录见闻B
将一条新知识/观察/经验记录入全量记忆库,自动分类、打标签、建索引
Inputs: content (required), tags, layer, space, +8 more.
万忆记忆自检A
全库健康度检测:记忆总数、各层分布、索引状态、FTS状态、图谱状态
Inputs: no named parameters.
万忆跨域桥接B
护城河#3「跨域类比迁移」:把交易/写作/开发各领域的教训抽象成跨域底层模式,然后跨域桥接——让交易的教训自动提醒写作/开发,反之亦然。BLOCK/CAUTION拦截时自动联动。abstract沉淀模式(abstract_name+essence+keywords)、bridge给定当前决策找跨域同构模式、list_patterns按命中率列出、get看详情。
Inputs: limit, action, domain, essence, +5 more.
万忆轨迹回放A
护城河#4「分支轨迹回放」:把历史所有反事实分支串成决策时间线,让你一眼看见每次听劝/不听劝的走向。timeline按时间回放全部分支、stats决策生涯统计(结算率/counter_won率/听劝验证率/风险分布/洞察)、route对比「实际路径 vs 如果全听劝路径」两条虚拟人生、review最近N天决策回顾。决策生涯可视化,越用越看得清自己的进化曲线。
Inputs: days, limit, action.
万忆过程存档A
过程记忆(ExpeL式):将任务执行的一个阶段(规划/尝试/纠错/反思/结论)存入轨迹档案,失败自动沉淀错题本,成功结论自动沉淀经验库,可设记忆锚点断点恢复
Inputs: phase (required), content (required), task_name (required), outcome, +2 more.
万忆错题本A
错题本(Reflexion式):查看错题/高频错误模式/补充教训。失败决策自动沉淀为反例条目,跨会话防重复犯错
Inputs: action, lesson, task_name, mistake_id.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 23 tools
Most tools target a distinct memory lifecycle or guardrail function, and the detailed descriptions help separate recall from graph search, consolidation from deep gardening, and the various moat tools. A few pairs (LOAD hook vs. proactive partner's brief, sleep consolidation vs. gardener) could still be confused at first glance.
All tools share the consistent 万忆 prefix, but the second element mixes noun-style names like 错题本 and 园艺师 with verb-object names like 记录见闻 and 更新交易锚点. The naming is readable, but there is no uniform verb_noun convention across the set.
With 23 tools, this sits in the heavy range, and many tools bundle multiple subcommands, making the actual surface even larger. The count is not absurd for a comprehensive memory-and-reflection system, but it feels over-scoped for a typical MCP server.
The server covers memory writing, recall, compression, consolidation, self-checks, hooks, progress persistence, and proactive guardrails very extensively. However, there is no explicit general memory update or delete/forget tool, which leaves a notable gap in the core CRUD lifecycle for arbitrary memories.
Maintenance
Related MCP Connectors
Persistent memory for AI agents. Semantic search, memory graph, W3C DID identity.
Persistent memory for AI agents. EU-hosted, privacy-first, hybrid recall, contradiction detection.
Memory, reflection and safety for AI agents. Hosted or local, no vector database.
Persistent memory and knowledge graphs for AI agents. Hybrid search, context checkpoints, and more.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to maintain persistent, local memory with retrieval-augmented search, knowledge graphs, and context surfacing, without any cloud dependencies.416 npmMIT
- AlicenseAqualityBmaintenanceGives AI agents persistent, local-first memory using SQLite and on-device embeddings, enabling semantic search and recall across sessions with no cloud calls.89MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to automatically capture durable knowledge and retrieve only relevant, token-bounded context from a secure local-first long-term memory, with support for progressive disclosure, snapshots, health diagnostics, and background tasks.Apache 2.0

slowaveofficial
AlicenseAqualityBmaintenanceProvides a local, adaptive memory layer that lets AI agents persist and retrieve decisions, constraints, and lessons across sessions without requiring an LLM API key.525AGPL 3.0