Memory Dreaming
Autonomous memory consolidation ("dreaming") for OpenClaw agents. Runs as a cron job, consolidates scattered daily notes into curated long-term memory, and syncs structured knowledge to an Obsidian vault.
Quick Start
- 1. Install: INLINECODE0
- Configure your vault path (optional): edit
dreaming-config.json in your workspace - Set up the cron: run INLINECODE2
- Done — the agent dreams automatically every 8 hours
To trigger a dream manually, tell the agent: "Run a dream cycle now."
How It Works
The dream cycle has 4 phases, inspired by biological REM sleep and Claude Code's AutoDream:
Phase 1: Orient
Read current memory state — MEMORY.md, recent daily logs, learnings, dreaming log. Build a map of what exists and when it was last touched.
Phase 2: Gather Signal
Search for high-value information added since the last dream:
- - Daily logs (
memory/YYYY-MM-DD.md) since last dream - Learnings (
.learnings/*.md) — pending corrections, errors, best practices - Session transcripts — grep for corrections ("actually...", "no that's wrong"), decisions ("let's do X"), proper nouns, preferences
- Plan files — scan workspace for
task_plan.md files
Key: grep narrowly for high-signal patterns. Don't read full transcripts — that burns tokens for marginal value.
Phase 3: Consolidate
Update MEMORY.md with gathered signal:
- - Merge duplicate entries (same fact from 3 sessions → one entry)
- Absolute dates — convert "yesterday" → "2026-03-25"
- Delete contradicted facts (if preference changed, remove old one)
- Remove stale entries (references to deleted files, completed tasks)
- Promote high-priority learnings from
.learnings/ to MEMORY.md
Phase 4: Sync
Push consolidated knowledge to external targets:
- - Obsidian vault (opt-in) — create/update notes with tags, wikilinks, full depth
- Plan tracking — ensure every
task_plan.md has a corresponding Plans/<name>.md in the vault - Dreaming log — write what changed, tokens used, duration
Gate
The cron fires on schedule but the dream cycle only executes if ≥6 hours have passed since the last dream (checked via dreaming-log.md timestamp). This prevents wasted runs when nothing has changed.
Configuration
Create dreaming-config.json in your workspace root to customize. All fields are optional — sensible defaults are used.
See assets/dreaming-config.json for the full schema with defaults.
Key options:
- -
schedule — cron expression (default: "0 */8 * * *") - INLINECODE14 — which model runs the dream (default:
"anthropic/claude-sonnet-4-6") - INLINECODE16 — minimum hours between dreams (default:
6) - INLINECODE18 — enable vault sync (default:
false) - INLINECODE20 — absolute path to Obsidian vault
- INLINECODE21 —
"none" or "announce" changes to a channel
Obsidian Sync Details
When enabled, the sync phase:
- 1. Compares MEMORY.md sections against existing vault notes
- Creates new notes in configured subfolders (
People/, Projects/, Plans/, Tools/) - Updates existing notes with new information (appends, doesn't overwrite)
- Follows formatting rules: tags on first line,
[[wikilinks]] throughout, full depth content - Tracks plans: scans for
task_plan.md files → creates/updates INLINECODE30
For detailed sync behavior, see references/obsidian-sync.md.
Manual Dream
Tell the agent any of these:
- - "Run a dream cycle"
- "Consolidate memory"
- "Dream now"
- "Sync to obsidian"
The agent reads this skill and executes the 4-phase cycle immediately, ignoring the gate.
Setup Script
CODEBLOCK0
The script reads dreaming-config.json (or uses defaults) and creates an isolated agentTurn cron job. See scripts/setup-cron.sh for details.
Architecture
For the detailed 4-phase architecture, design decisions, and how this compares to Claude Code AutoDream, see references/architecture.md.
What This Skill Does NOT Do
- - Does not replace QMD indexing (QMD handles search, this handles consolidation)
- Does not delete source files (daily logs are never removed, only consolidated from)
- Does not modify source code or project files
- Does not run without explicit setup (cron must be created via setup script)
记忆梦境
OpenClaw智能体的自主记忆整合(梦境)功能。作为定时任务运行,将分散的日常笔记整合为精选的长期记忆,并将结构化知识同步至Obsidian知识库。
快速开始
- 1. 安装:clawhub install oryanmoshe/memory-dreaming
- 配置知识库路径(可选):编辑工作区中的dreaming-config.json
- 设置定时任务:运行scripts/setup-cron.sh
- 完成——智能体每8小时自动执行一次梦境周期
如需手动触发梦境,请告知智能体:立即执行一次梦境周期。
工作原理
梦境周期包含4个阶段,灵感来源于生物REM睡眠和Claude Code的AutoDream:
阶段1:定向
读取当前记忆状态——MEMORY.md、近期日常日志、学习记录、梦境日志。构建现有内容及其最后更新时间的地图。
阶段2:信号收集
搜索自上次梦境以来新增的高价值信息:
- - 日常日志(memory/YYYY-MM-DD.md)——自上次梦境以来的记录
- 学习记录(.learnings/*.md)——待修正内容、错误、最佳实践
- 会话记录——通过grep搜索修正内容(实际上...、不,那是错的)、决策(我们来做X)、专有名词、偏好
- 计划文件——扫描工作区中的task_plan.md文件
关键:精确使用grep搜索高信号模式。不要读取完整会话记录——那会消耗大量token而收益甚微。
阶段3:整合
使用收集到的信号更新MEMORY.md:
- - 合并重复条目(同一事实来自3个会话→合并为一个条目)
- 绝对日期——将昨天转换为2026-03-25
- 删除矛盾事实(如果偏好已更改,移除旧条目)
- 移除过时条目(引用已删除文件、已完成任务的条目)
- 提升从.learnings/中提取的高优先级学习记录至MEMORY.md
阶段4:同步
将整合后的知识推送至外部目标:
- - Obsidian知识库(可选)——创建/更新带有标签、维基链接和完整深度的笔记
- 计划追踪——确保每个task_plan.md在知识库中都有对应的Plans/<名称>.md
- 梦境日志——记录变更内容、消耗的token、持续时间
门控机制
定时任务按计划触发,但仅当距离上次梦境≥6小时(通过dreaming-log.md时间戳检查)时才会执行梦境周期。这可在无变更时避免无效运行。
配置
在工作区根目录创建dreaming-config.json进行自定义。所有字段均为可选——将使用合理的默认值。
参见assets/dreaming-config.json获取包含默认值的完整架构。
关键选项:
- - schedule——cron表达式(默认:0 /8 )
- model——执行梦境的模型(默认:anthropic/claude-sonnet-4-6)
- gate.minHours——梦境间的最小间隔小时数(默认:6)
- obsidian.enabled——启用知识库同步(默认:false)
- obsidian.vaultPath——Obsidian知识库的绝对路径
- delivery.mode——none或announce将变更通知到频道
Obsidian同步详情
启用后,同步阶段将:
- 1. 将MEMORY.md的各个部分与现有知识库笔记进行比较
- 在配置的子文件夹(People/、Projects/、Plans/、Tools/)中创建新笔记
- 使用新信息更新现有笔记(追加内容,不覆盖)
- 遵循格式规则:标签在第一行,全文使用[[维基链接]],完整深度内容
- 追踪计划:扫描task_plan.md文件→创建/更新Plans/<名称>.md
详细同步行为参见references/obsidian-sync.md。
手动梦境
告知智能体以下任一指令:
- - 执行一次梦境周期
- 整合记忆
- 立即做梦
- 同步到obsidian
智能体将读取此技能并立即执行4阶段周期,忽略门控机制。
设置脚本
bash
在OpenClaw中创建定时任务
bash scripts/setup-cron.sh
该脚本读取dreaming-config.json(或使用默认值)并创建一个独立的agentTurn定时任务。详情参见scripts/setup-cron.sh。
架构
关于详细的4阶段架构、设计决策以及与此Claude Code AutoDream的比较,参见references/architecture.md。
此技能不执行的操作
- - 不替代QMD索引(QMD负责搜索,此技能负责整合)
- 不删除源文件(日常日志从不删除,仅从中整合内容)
- 不修改源代码或项目文件
- 未经明确设置不运行(必须通过设置脚本创建定时任务)