中文 / English
luckfu's notes.

Never forget your dreams!


  • Home

  • Archive

  • About

  • Page404

  • Search

I Fixed a Bug in OpenClaw Dreaming — The Regex That Broke the Memory System

Published at: 2026/04/08   |   Categories: Tech   OpenClaw   Bug Fix   | Words: 720 words | Reading: 2 minutes | Visited:

龙虾做梦图

Background

OpenClaw’s Dreaming feature (background memory consolidation) is an experimental capability designed to:

  1. Light Phase: Scan recent memory files, extract key content into the short-term recall store
  2. REM Phase: Deduplicate and cluster the recall store
  3. Deep Phase: For sufficiently rich recall, call the LLM to generate a deep summary, write to DREAMS.md, and optionally promote it to MEMORY.md

Configured to run automatically at 04:00 daily (customizable). Sounds great.

But in reality: enabling it had zero effect — no output whatsoever.


Symptoms

  • Dreaming config shows enabled: true, cron schedule is correct
  • openclaw memory status shows recall store always empty: 0 entries · 0 promoted
  • DREAMS.md never generated
  • memory/.dreams/short-term-recall.json does not exist
  • Gateway logs show no errors, only silent “No short-term recall candidates.”

Investigation

Layer 1: Suspect Plugin / Config

Checked plugins.entries.memory-core.config.dreaming — config path correct, frequency set to 0 4 * * *. /dreaming on and /dreaming status both respond normally. Config is fine.

Layer 2: Suspect Recall Store Write Permissions

Checked /home/opc/.openclaw/workspace/memory/.dreams/ — directory exists, permissions normal. Not a permission issue.

Layer 3: Suspect Trigger Channel

Manually injected __openclaw_memory_core_short_term_promotion_dream__ event into the main session. The Hook was called (DREAMING_HOOK_FIRED_UNMISTAKABLE appeared in logs), the Pipeline executed but returned executed: false. The trigger channel works — problem is inside the pipeline.

Layer 4: Suspect Recall Store Content

Checked recall store: short-term-recall.json exists but entryCount: 0. Checked memory file list — canonical daily files stopped existing after 2026-04-04:

memory/2026-04-03.md         ✅  Last standard file
memory/2026-04-04-x-credentials.md   ❌ (not YYYY-MM-DD)
memory/2026-04-07-title-copy.md      ❌ (not YYYY-MM-DD)

Checked session hook logs: OpenClaw’s built-in hooks/session-memory writes session fragment files in YYYY-MM-DD-HHMM.md format, not the YYYY-MM-DD.md format Dreaming requires.

Layer 5: Deep Dive into Code

Read the compiled dist files, found the key function isShortTermMemoryPath():

// Original regex (broken)
const RE = /(?:^|\/)memory\/(\d{4})-(\d{2})-(\d{2})\.md$/;

This regex only matches memory/2026-04-03.md — completely fails to match memory/2026-04-07-title-copy.md.

And recordShortTermRecalls() has the write condition:

if (result.source !== "memory") return;
if (!isShortTermMemoryPath(result.path)) return;
// write to recall store ← skipped silently here

Both conditions must pass to write. As long as the filename doesn’t match the regex, writes are silently skipped with no logs.


Root Cause

OpenClaw’s session-memory hook changed the memory file naming convention: from standard YYYY-MM-DD.md to YYYY-MM-DD-HHMM.md (session fragments). But Dreaming’s short-term recall entry regex was still the old one — only matching the standard format.

The resulting chain: session-memory writes YYYY-MM-DD-HHMM.md → Dreaming regex doesn't match → recall store stays empty → REM phase has no input → Deep phase doesn't trigger → DREAMS.md never generated

This is a classic “interface contract mismatch” bug: both modules work correctly in isolation, but their input/output formats don’t align.


The Fix

Modified the regex in short-term-promotion-G9ML8hkA.js:

// Before
const RE = /(?:^|\/)memory\/(\d{4})-(\d{2})-(\d{2})\.md$/;

// After
const RE = /(?:^|\/)memory\/(\d{4})-(\d{2})-(\d{2})(?:-.*)?\.md$/;

(?:-.*)? matches an optional -suffix part (suffix can be -HHMM or -arbitrary-topic).

Two additional minor improvements were made in dreaming-CnlsXIYM.js (nice-to-have):

  1. Trigger allowlist broadened: expanded from only accepting heartbeat to ["heartbeat", "system", "cron"]
  2. Telegram reminder text parsing: correctly extracts the raw event name from “A scheduled reminder has been triggered. The reminder content is: xxx”

Validation

After patching, manually injected a cron probe:

Schedule: 2026-04-08T06:50:48.000Z (14:50:48 CST) Payload: __openclaw_memory_core_short_term_promotion_dream__

Result:

DREAMING_HOOK_FIRED_UNMISTAKABLE >>> trigger=heartbeat bodyLen=...
Executing pipeline... done (executed: false, success: true)

executed: false is expected — the day’s recall store entries were insufficient (threshold ≥ 3), so LLM did not generate a summary. The Pipeline completed fully; it just needs more content accumulated.

Dreaming is now end-to-end functional.


Lessons Learned

  1. When encountering “silent failures”, go read the dist source code first, don’t guess. OpenClaw’s error handling is clean — it won’t volunteer errors, you have to trace the conditional branches yourself.

  2. Interface contract mismatch is a classic distributed systems bug. Both modules work, but formats don’t align. Recommended fix: add broader filename matching in isShortTermMemoryPath(), or make the session-memory hook write standard daily files by default.

  3. The params.trigger value in a Hook is not necessarily the original event type. When a cron-triggered event reaches the before_agent_reply hook, the trigger value is "heartbeat" not "cron" — this is OpenClaw’s internal event routing.

  4. On next upgrade, only one patch location needs checking: short-term-promotion-G9ML8hkA.js. The other two changes are nice-to-have and don’t affect core functionality.


「独断万古,恐怖如斯。」 — 如烟大帝, 2026-04-08, from a battle with regular expressions

#OpenClaw# #Dreaming# #Bug Fix# #Memory System# #Regex#

Declaration:I Fixed a Bug in OpenClaw Dreaming — The Regex That Broke the Memory System

Link:https://luckfu.github.io/en/post/2026-04-08_openclaw-dreaming-fix/

Author:luckfu

Declaration: This blog post article is under the CC BY-NC-SA 3.0 license,Please indicate the source!

If it can help you, you can give tips for blogger that how much you want. ^_^
WeChat Pay

Wechat Pay

Alipay

Ali Pay

paypal Pay

PayPal

Why Does A-Shares Always End Up Paying the Bill?
Metabase Connect to Oracle Autonomous Database using wallet
  • Table of Content
  • Site Information
luckfu

luckfu

In a flash, all of the past away from you, the rest of the only memories.

7 Blogs
15 Categories
24 Tags
GitHub
TagCloud
  • Oracle cloud
  • Free vps
  • Vm.standard.a1.flex
  • A shares
  • Automation script
  • Bluetooth pan
  • Bug fix
  • China market
  • Docker
  • Dreaming
  • Background
  • Symptoms
  • Investigation
    • Layer 1: Suspect Plugin / Config
    • Layer 2: Suspect Recall Store Write Permissions
    • Layer 3: Suspect Trigger Channel
    • Layer 4: Suspect Recall Store Content
    • Layer 5: Deep Dive into Code
  • Root Cause
  • The Fix
  • Validation
  • Lessons Learned
© 2010 - 2026 luckfu's notes.
Powered by - Hugo v0.127.0 / Theme by - NexT
0%