Skip to content

feat: dream plugin#1662

Merged
bittergreen merged 3 commits intoMemTensor:mainfrom
CaralHsi:feat/ce-dream-0507-pr
May 9, 2026
Merged

feat: dream plugin#1662
bittergreen merged 3 commits intoMemTensor:mainfrom
CaralHsi:feat/ce-dream-0507-pr

Conversation

@CaralHsi
Copy link
Copy Markdown
Collaborator

@CaralHsi CaralHsi commented May 8, 2026

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).

Without motives, it's batch summarization, not dreaming.

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

Form Motives  →  Recall Around Motives  →  Directed Dream  →  Persist
(why dream?)     (cross-type recall)       (consolidate)      (diary + memory)
Step Stage Description
1 MotiveFormation LLM-powered: cluster pending memories into motives by identifying cross-conversation patterns, unresolved tensions, and repeated themes
2 DirectRecall Embedding-based similarity search across UserMemory and LongTermMemory
3 ConsolidationReasoning LLM-powered deep dreaming: reframe problems and produce concrete insights with hypothetical-deduction rationale
4a StructuredDiarySummary Package into human-readable diary (deterministic, no LLM)
4b DreamPersistence Execute DreamActions against graph_db + persist diary

Steps 1 & 3 gracefully degrade to heuristic fallbacks when LLM is unavailable. Each stage is independently replaceable.

Integration

  • Plugin system: Discovered and loaded via the MemOS plugin manager — zero coupling to core if not installed
  • Scheduler: MemDreamMessageHandler consumes dream tasks from the scheduler queue
  • Hooks: Piggybacks on add.after hook to accumulate signals; fires dream.before_persist / dream.after_persist for extensibility
  • API: Adds /dream/trigger/cube, /dream/diary, /dream/diary/health endpoints

What'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 wiring
  • examples/dream/full_pipeline_example.py — end-to-end runnable example

概要

新增 MemOS Dream —— 一个由动机驱动的离线记忆重组插件。它模拟人脑做梦的机制:先从未解决的内在动机出发(而非原始记忆列表),围绕动机跨类型召回异构记忆,经过推理整合后以梦境日记(可解释追溯)和梦境记忆(影响未来行为)两条线持久化。

没有"梦因"的 Dream 只是批处理总结,不是真正的梦。

设计理念

人脑的梦围绕几类东西打转:反复激活的事物、未完成的目标、情绪强烈的事件、冲突的信息、预期未来会用到的内容。Dream 模拟这一点——先把待处理记忆聚成动机簇,再围绕动机做定向推理,产出跨对话维度的洞察,这是单次白天对话无法达到的。

Pipeline

形成梦因  →  围绕动机召回  →  定向做梦  →  持久化
(为什么值得梦)  (跨记忆类型)    (重组/整合)   (日记 + 记忆)
步骤 阶段 说明
1 MotiveFormation LLM 驱动:识别跨对话模式、未解决张力和重复主题,分组为梦因簇
2 DirectRecall 基于 embedding 在 UserMemory / LongTermMemory 范围内语义召回
3 ConsolidationReasoning LLM 驱动的深度做梦:重构问题、产出具体洞察,附带假设演绎论证
4a StructuredDiarySummary 包装为人类可读日记条目(确定性,无 LLM)
4b DreamPersistence graph_db 执行 DreamActions + 持久化日记

步骤 1 和 3 在 LLM 不可用时自动回退为启发式策略。每个阶段可独立替换。

集成方式

  • 插件系统:通过 MemOS 插件管理器发现和加载——未安装时对核心零耦合
  • 调度器MemDreamMessageHandler 从调度器队列消费 dream 任务
  • Hook 机制:挂载在 add.after hook 上累积信号;执行时触发 dream.before_persist / dream.after_persist 用于扩展
  • API:新增 /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 — 端到端可运行示例

CaralHsi and others added 2 commits May 8, 2026 22:13
Co-authored-by: Cursor <cursoragent@cursor.com>
@CaralHsi CaralHsi marked this pull request as ready for review May 8, 2026 14:25
@CaralHsi CaralHsi requested review from bittergreen May 8, 2026 14:27
bittergreen
bittergreen approved these changes May 9, 2026
@bittergreen bittergreen merged commit f90187a into MemTensor:main May 9, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants