feat: dream plugin#1662
Merged
bittergreen merged 3 commits intoMemTensor:mainfrom May 9, 2026
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
bittergreen
approved these changes
May 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add MemOS Dream — a motive-driven, offline memory consolidation plugin that mirrors how human dreams work: it starts from unresolved internal motives (not a raw memory list), recalls heterogeneous memories around those motives, and persists the results as both dream diaries (explainable traces) and dream memories (affecting future behavior).
Design Philosophy
Human dreams revolve around repeatedly activated things, unfinished goals, emotionally intense events, conflicting information, and anticipated future needs. Dream mirrors this by clustering pending memories into internal motives first, then reasoning over them to produce cross-session insights that no single daytime conversation could have reached.
Pipeline
MotiveFormationDirectRecallUserMemoryandLongTermMemoryConsolidationReasoningStructuredDiarySummaryDreamPersistencegraph_db+ persist diarySteps 1 & 3 gracefully degrade to heuristic fallbacks when LLM is unavailable. Each stage is independently replaceable.
Integration
MemDreamMessageHandlerconsumes dream tasks from the scheduler queueadd.afterhook to accumulate signals; firesdream.before_persist/dream.after_persistfor extensibility/dream/trigger/cube,/dream/diary,/dream/diary/healthendpointsWhat's Included
src/memos/dream/— full plugin implementation (plugin, hooks, pipeline stages, prompts, routers, types)src/memos/plugins/— plugin framework enhancements (hook registration, component bootstrap, manager)src/memos/mem_scheduler/— dream handler + registry wiringexamples/dream/full_pipeline_example.py— end-to-end runnable example概要
新增 MemOS Dream —— 一个由动机驱动的离线记忆重组插件。它模拟人脑做梦的机制:先从未解决的内在动机出发(而非原始记忆列表),围绕动机跨类型召回异构记忆,经过推理整合后以梦境日记(可解释追溯)和梦境记忆(影响未来行为)两条线持久化。
设计理念
人脑的梦围绕几类东西打转:反复激活的事物、未完成的目标、情绪强烈的事件、冲突的信息、预期未来会用到的内容。Dream 模拟这一点——先把待处理记忆聚成动机簇,再围绕动机做定向推理,产出跨对话维度的洞察,这是单次白天对话无法达到的。
Pipeline
MotiveFormationDirectRecallUserMemory/LongTermMemory范围内语义召回ConsolidationReasoningStructuredDiarySummaryDreamPersistencegraph_db执行 DreamActions + 持久化日记步骤 1 和 3 在 LLM 不可用时自动回退为启发式策略。每个阶段可独立替换。
集成方式
MemDreamMessageHandler从调度器队列消费 dream 任务add.afterhook 上累积信号;执行时触发dream.before_persist/dream.after_persist用于扩展/dream/trigger/cube、/dream/diary、/dream/diary/health端点本 PR 包含
src/memos/dream/— 完整插件实现(插件入口、hook、pipeline 各阶段、prompt、路由、类型定义)src/memos/plugins/— 插件框架增强(hook 注册、组件引导、管理器)src/memos/mem_scheduler/— dream handler + registry 注册examples/dream/full_pipeline_example.py— 端到端可运行示例