Skip to content

Dreaming system pollutes daily memory files, causing heartbeat agents to skip memory logging #66947

@jensenwang560-blip

Description

@jensenwang560-blip

Problem

The dreaming system (memory-core plugin) writes its Light Sleep and REM Sleep phase blocks directly into memory/YYYY-MM-DD.md files in the agent's workspace. This causes the agent's heartbeat to see "today's daily file already exists" and skip scanning for real session activity to log — resulting in days with zero agent-curated content despite active conversations.

Root Cause

writeDailyDreamingPhaseBlock (in extensions/memory-core/src/dreaming-markdown.ts, called by the Light and REM phase runners) writes dreaming output into the same memory/YYYY-MM-DD.md files that agents use for daily logs. The dreaming sweep runs at 3 AM by default (dreaming.frequency, default 0 3 * * *). By the time the first real heartbeat fires later that day, the file already exists with dreaming content. The heartbeat agent (an LLM, not deterministic code) then judges "file exists, nothing new" and replies HEARTBEAT_OK without logging any actual session activity.

The default storage.mode is "inline" (see DEFAULT_MEMORY_DREAMING_STORAGE_MODE in src/memory-host-sdk/dreaming.ts), which is what triggers the inline write.

Observed Behavior

  • memory/2026-04-14.md for agent Chelsea contains ONLY dreaming Light/REM blocks and zero agent-written content, despite 10+ user conversations that day.
  • memory/2026-04-15.md for agent Clawdea: same issue — only dreaming blocks, no curated notes.
  • Heartbeat sessions show the agent explicitly noting "Today's file is just dreaming output, no actual session activity logged" but then doing nothing about it and replying HEARTBEAT_OK.
  • Dreaming "themes" are low quality — surfacing stop-words like "assistant", "the", "let" as patterns.

Evidence That The Codebase Already Treats Dreaming Blocks As Separate Concerns

  • A "separate" storage mode is already implemented: resolveSeparateReportPath writes to memory/dreaming/<phase>/YYYY-MM-DD.md. The Deep phase already uses this location exclusively.
  • stripManagedDailyDreamingLines exists on the ingest side and strips dreaming blocks before reading, confirming the system already knows these blocks are "not real content". The fix is to stop writing them into the daily file in the first place.

Proposed Fix

Change the default storage.mode from "inline" to "separate" in src/memory-host-sdk/dreaming.ts (and the matching fallback in extensions/memory-core/src/dreaming.ts). The plumbing is already there — only the default changes.

This cleanly separates automated dreaming output from the agent's curated daily log. Existing configs that explicitly set storage.mode are unaffected.

Config Reference

{
  "plugins": {
    "entries": {
      "memory-core": {
        "config": {
          "dreaming": {
            "enabled": true,
            "timezone": "Asia/Shanghai"
          }
        }
      }
    }
  }
}

Additional Notes

  • Historical polluted files (e.g. memory/2026-04-14.md) still contain inline dreaming blocks after the default change. Cleanup would need a separate migration or manual intervention.
  • The 3-phase dreaming system (Light pattern detection, REM reflection/consolidation, Deep promotion to MEMORY.md) is otherwise unchanged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions