
记忆梦境引擎 · AI 的睡眠系统
cn.savantcatv1.0.1Updated Oct 6, 2026
零 LLM 事实提取 + 三维信号评分 + 艾宾浩斯衰减 + 五阶段梦境流水线与内容发芽检测,纯计算零依赖
Overview
A local MCP server that extracts, scores, decays and consolidates an assistant's long-term memories, and flags when accumulated notes could become content.
- What it does
- It exposes six tools: extract_facts for regex-based fact extraction in Chinese and English without any LLM calls, score_signal for three-dimensional scoring of whether a signal belongs in long-term memory, decay_report for Ebbinghaus-style strength, access boost, archival decisions and a full curve, simulate_dream for running a complete five-stage dream cycle over supplied text in a temporary store, list_signal_types for the four signal dimensions and their weights, and engine_info for a capability overview. The engine itself is pure computation over SQLite with no third-party dependencies.
- When to use it
- Worth adding when an assistant's memory grows unbounded and you want scoring, decay and cleanup decisions rather than raw storage, or when you want to test how a batch of notes would be consolidated before wiring it into a framework. It is a computation and reporting layer, not a memory backend that stores your assistant's data.
- Requirements
- Runs as a local stdio process started with python server.py, or over streamable-http with a port argument. Needs Python and the mcp package (mcp>=2.1); pytest only for the test suite. No API keys, no environment variables, no accounts. Desktop only; not executable in a browser.
Installation
In SourceWeft
- Open 记忆梦境引擎 · AI 的睡眠系统 in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
🌙 记忆梦境引擎 · Memory Dream Engine
你的 AI 聊完就忘,不是它笨 —— 是它从来不做梦。
一个可插拔的「AI 睡眠系统」:采集 → 评分 → 写入 → 优化 → 发芽,每 3 小时自动跑一轮。 零 LLM 成本、纯标准库、~800 行 Python、8/8 单元测试通过。
[License] [Python] [Tests] [Deps]
🤔 你大概率遇到过这三种情况
梦境引擎就是补这三环的。
🧠 它怎么工作 —— 像人一样睡觉
⚡ 四个「别人没有」的点
🆚 和溯忆(Suyi)比
溯忆是被动存储,梦境引擎是主动生长:
🚀 60 秒跑起来
想看核心能力,直接跑引擎自带的 v3 演示:
🔌 接入你自己的 Agent
引擎不绑定任何框架,只需实现三个适配器函数:
⚠️ 文档澄清:早期版本的 README 里出现过「编辑
.env配置SESSION_SEARCH_FN/MEMORY_FN」的说明, 那是错的 —— 引擎从不读取任何环境变量。接入方式只有上面这一种:传 Python 函数。
🔌 作为 MCP 服务调用
server.py 把引擎包成标准 MCP server —— 别人的 Agent 可以直接调这几个工具,不必接适配器、不必读源码。
客户端配置(stdio):
服务端为纯计算、纯读:6 个工具的四个 annotation hint 全部声明(readOnlyHint=true / destructiveHint=false / idempotentHint=true / openWorldHint=false),不需要 API Key,也不保存调用方的任何数据 —— simulate_dream 在临时库跑完即销毁。
⏰ 定时运行(Hermes Agent)
⚠️ 必读:Cron 环境写不了 Memory(最大的运维坑)
多数 Agent 框架的 cron 子进程没有 memory 工具权限,会导致阶段 3(写入)和阶段 4(优化)静默失败 —— 引擎照常采集和评分,但 ≥70 分的条目会持续积压。
症状:报告反复出现「阶段3:写入 — 受阻」,同一批高分记忆连着几轮都没写进去。
做法:每跑 3 轮 cron,安排一次交互式会话手动补写阶段 3+4;memory 占用到 95% 时立即执行清理。
📁 项目结构
🧪 测试
测试为 pytest 风格(裸 assert +
setup_method夹具),不兼容unittest discover,请用 pytest 运行。 夹具名必须是setup_method—— pytest 8 已移除旧的setup约定,写成setup在 CI 上会集体报AttributeError(本地老版本 pytest 却照过,是个只在 CI 才暴露的坑)。
📄 License
MIT — 自由使用、修改、分发。
👤 作者
合尘猫 · 一个人 + 一个 AI 分身的 AI 落地实践 —— 知识库 · AI 客服合规 · 内容自动化。
- 🏠 更多作品与实战记录:https://savantcat.cn
- 🐙 全部开源仓库:https://gitee.com/savantcat
如果这个引擎帮你的 AI 真正"记住"了什么,给个 ⭐ 就是最好的反馈。
记忆不是越多越好,而是越「活」越好。
Source: README.md at commit 583cb4c
Tools
0Version history
1- v1.0.1LatestOct 6, 2026


