openclaw - 💡(How to fix) Fix Dreaming diary (DREAMS.md) grows without bound — no rotation or size cap

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

The dreaming narrative phase appends diary entries to DREAMS.md on every cycle but never prunes, rotates, or caps the file size. Over time the file grows without limit.

Error Message

Two agents running for ~6 weeks both accumulated >130 KB dream diaries:

Root Cause

In dreaming-phases the narrative output is appended via replaceDiaryContent() (insert between start/end markers). There is no:

  • Maximum file size or entry count check
  • Rotation (e.g. keep last N entries or last N days)
  • Archival of old entries to a separate file
  • Any pruning mechanism

The only cleanup in the dreaming pipeline is session-store scrubbing (prunedEntries), not diary file management.

RAW_BUFFERClick to expand / collapse

Summary

The dreaming narrative phase appends diary entries to DREAMS.md on every cycle but never prunes, rotates, or caps the file size. Over time the file grows without limit.

Observed behavior

Two agents running for ~6 weeks both accumulated >130 KB dream diaries:

  • Agent A: 134 KB (kagura, daily dreaming since mid-April)
  • Agent B: 141 KB (ruantang, same period)

Impact

DREAMS.md is loaded as workspace project context and injected into every prompt. A 140 KB file significantly increases prompt size, adding latency and token cost to every turn — even for lightweight conversations that have nothing to do with dreams or memory.

Root cause

In dreaming-phases the narrative output is appended via replaceDiaryContent() (insert between start/end markers). There is no:

  • Maximum file size or entry count check
  • Rotation (e.g. keep last N entries or last N days)
  • Archival of old entries to a separate file
  • Any pruning mechanism

The only cleanup in the dreaming pipeline is session-store scrubbing (prunedEntries), not diary file management.

Suggested fix

Add a size or entry cap to the dream diary, for example:

  1. Entry cap: keep the most recent N entries (e.g. 30), archive or discard older ones
  2. Size cap: if DREAMS.md exceeds a threshold (e.g. 20 KB), trim oldest entries
  3. Rotation: move old entries to DREAMS-archive-YYYY-MM.md (not loaded as context)

Any of these would prevent unbounded growth while preserving the dreaming feature.

Environment

  • OpenClaw 2026.5.22
  • Dreaming enabled with default config
  • Two agents affected (different workspaces)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Dreaming diary (DREAMS.md) grows without bound — no rotation or size cap