openclaw - ✅(Solved) Fix [Bug] Dreaming raw candidates pollute daily memory files (memory/YYYY-MM-DD.md) [4 pull requests, 1 participants]

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…
GitHub stats
openclaw/openclaw#70509Fetched 2026-04-24 05:57:13
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
cross-referenced ×4referenced ×1

Fix Action

Fixed

PR fix notes

PR #70523: fix(memory-core): suppress raw dreaming inline dumps on fallback (Fixes #70509)

Description (problem / solution / changelog)

Summary

Problem

When dreaming narrative generation falls back because the subagent runtime is request-scoped, the inline memory/YYYY-MM-DD.md dreaming blocks still write the raw light/REM candidate dump. That leaves daily memory files full of structured dreaming metadata instead of normal human-readable notes.

Why it matters

  • Daily memory files become noisy and harder to read.
  • The raw candidate dump is machine-oriented metadata, not user-facing memory.
  • The repo already treats these dreaming snippets as contamination in other memory paths, so daily writes should not keep surfacing them during fallback runs.

What changed

  • Reused the existing dreaming contamination helper from short-term promotion.
  • Taught dreaming phases to detect when narrative generation used the request-scoped fallback.
  • Suppressed only the inline daily dreaming block in that fallback case when the block is clearly raw candidate/reflection metadata.
  • Kept separate dream diary writes and normal successful inline dreaming behavior unchanged.
  • Added regression tests for both light-sleep candidate dumps and REM reflection dumps.

What did NOT change

  • No change to successful narrative generation behavior.
  • No change to separate dreaming reports or DREAMS.md writes.
  • No change to promotion ranking or durable MEMORY.md application.

Change Type

  • Bug fix
  • Tests

Scope

  • extensions/memory-core/src/dreaming-phases.ts
  • extensions/memory-core/src/dreaming-markdown.ts
  • extensions/memory-core/src/dreaming-narrative.ts
  • extensions/memory-core/src/short-term-promotion.ts
  • extensions/memory-core/src/dreaming-phases.test.ts

Linked Issue

Closes #70509

User-visible / Behavior Changes

  • If dreaming runs in inline storage mode and the dream diary narrative has to fall back because the subagent runtime is request-scoped, OpenClaw now keeps the raw dreaming dump out of memory/YYYY-MM-DD.md.
  • The fallback narrative still lands in DREAMS.md, so the dreaming run still leaves a human-readable artifact.

Security Impact

Low risk, positive direction. This reduces the chance that raw dreaming metadata and evidence-style snippets get copied into user-facing daily memory files during fallback runs.

Repro + Verification

Environment

  • Local worktree off current upstream/main
  • Node / Vitest in this environment still have unrelated repo-level issues

Steps

  1. Configure memory-core dreaming with inline storage.
  2. Trigger light or REM dreaming with a subagent surface that throws RequestScopedSubagentRuntimeError.
  3. Inspect memory/YYYY-MM-DD.md and DREAMS.md.

Expected

  • Daily memory file keeps the original human notes and does not gain a raw ## Light Sleep / ## REM Sleep metadata dump.
  • DREAMS.md still receives the fallback narrative entry.

Actual before this patch

  • Daily memory file received the raw candidate / reflection block even when the narrative path had already fallen back.

Evidence

  • git diff --check
  • Added regression coverage in extensions/memory-core/src/dreaming-phases.test.ts
  • Focused TypeScript scan did not surface errors in the touched dreaming files

Human Verification

  • Not fully runnable here: the repo-level Vitest startup currently trips over the existing config discovery error for test/vitest/vitest.contracts-channel-surface.config.ts.
  • Broader tsc -p tsconfig.extensions.test.json --noEmit also fails in this environment on many unrelated missing extension dependencies, but none of the reported errors were in the touched dreaming files.

Compatibility / Migration

None.

Failure Recovery

Revert this PR. The change is isolated to dreaming inline-write suppression during fallback and does not alter stored data formats.

Risks and Mitigations

  • Risk: suppressing inline blocks too broadly could hide intended dreaming output.
  • Mitigation: the suppression only triggers when narrative generation explicitly used the request-scoped fallback and the inline block matches the raw dreaming metadata shape.

Changed files

  • docs/help/faq.md (modified, +29/-0)
  • extensions/memory-core/src/dreaming-markdown.test.ts (modified, +41/-0)
  • extensions/memory-core/src/dreaming-markdown.ts (modified, +51/-8)
  • extensions/memory-core/src/dreaming-narrative.test.ts (modified, +20/-0)
  • extensions/memory-core/src/dreaming-narrative.ts (modified, +16/-9)
  • extensions/memory-core/src/dreaming-phases.test.ts (modified, +90/-0)
  • extensions/memory-core/src/dreaming-phases.ts (modified, +64/-38)
  • extensions/memory-core/src/short-term-promotion.ts (modified, +1/-1)

PR #65138: Fix dreaming replay, repair polluted artifacts, and gate wiki tabs

Description (problem / solution / changelog)

What This PR Does

This PR fixes two user-visible memory problems and wires the recovery flow through the product surfaces that already expose dreaming state.

1. Active memory now keeps recall on the right channel

The branch fixes channel selection for active-memory recall runs so recall follows the resolved session/channel context instead of drifting to a weaker wrapper/provider hint.

Before this change, the recall path could flatten these inputs incorrectly:

explicit channel hint
session store channel
session origin provider
wrapper/provider fallback

Now the selection is ordered by trust and keeps parent-session context when it exists.

flowchart TD
    A["Explicit channel hint"] --> B
    S["Session store: lastChannel/channel"] --> B
    O["Session origin provider"] --> B
    W["Wrapper/provider fallback"] --> B
    B["Resolve recall run channel context"] --> C["Recall runs on the resolved channel"]

In practice, this means recall jobs stay attached to the channel the conversation actually belongs to instead of hopping to a weaker inferred provider value.

2. Managed dreaming no longer replays the same event and spiral-loops on itself

The branch fixes the main dreaming failure mode that produced the half-hourly spam.

There were two separate problems:

  1. A managed dreaming system event could be inspected by heartbeat and then replayed again instead of being consumed once.
  2. Dreaming could ingest its own narrative transcripts back into future dream runs.

Before:

flowchart LR
    A["Managed dreaming event queued once"] --> B["Heartbeat inspects event"]
    B --> C["Dreaming run writes diary + narrative transcript"]
    C --> D["Event not fully consumed or later replayed"]
    C --> E["Narrative transcript re-enters dream corpus"]
    D --> B
    E --> C

After:

flowchart LR
    A["Managed dreaming event queued once"] --> B["Heartbeat inspects exact queued entries"]
    B --> C["Successful dreaming run"]
    C --> D["Consume only inspected entries"]
    C --> E["Skip dreaming-generated transcripts during corpus ingestion"]
    D --> F["Later events remain queued for later heartbeats"]
    E --> G["No self-ingestion loop"]

Concretely, the runtime changes are:

  • src/infra/heartbeat-runner.ts now consumes inspected system events on success and on the no-tasks-due early-return path.
  • src/infra/system-events.ts now removes only the exact inspected queued entries instead of draining the whole session queue.
  • src/memory-host-sdk/host/session-files.ts and packages/memory-host-sdk/src/host/session-files.ts mark dreaming-generated transcripts, and extensions/memory-core/src/dreaming-phases.ts skips them during corpus ingestion.

This closes both the replay bug and the “dreaming about its own dreams” feedback loop.

3. Dreaming repair and diary cleanup are now explicit product actions

Once the runtime was fixed, the next problem was cleanup of already-polluted derived state. This PR adds one shared repair backend in memory-core and exposes it consistently.

flowchart TD
    A["Polluted dream artifacts"] --> B["memory-core repair API"]
    B --> C["CLI: openclaw memory status --fix"]
    B --> D["CLI: openclaw doctor --fix"]
    B --> E["Control UI: Repair Dream Cache"]
    B --> F["Control UI: Dedupe Diary"]

The repair model is intentionally conservative:

  • Repair Dream Cache archives and resets derived dream artifacts such as memory/.dreams/session-corpus and memory/.dreams/session-ingestion.json.
  • Dedupe Diary rewrites DREAMS.md, but only removes exact duplicate diary blocks.
  • DREAMS.md is not silently deleted by cache repair.

The dedupe rule is intentionally narrow:

fingerprint = normalizedTimestamp + "\n" + normalizedBody

That means we remove only exact same-timestamp / same-body duplicates, not fuzzy “similar” entries.

4. Diary rewrites are now serialized

The branch also fixes a write race on DREAMS.md.

Before, append/dedupe/backfill paths each did their own read-modify-write cycle. If two paths ran together, one could overwrite the other.

Now all diary mutations go through one locked update path in extensions/memory-core/src/dreaming-narrative.ts.

sequenceDiagram
    participant A as Append
    participant B as Dedupe
    participant L as Per-file async lock
    participant F as DREAMS.md
    A->>L: acquire
    A->>F: read/update/write
    A-->>L: release
    B->>L: acquire
    B->>F: read/update/write
    B-->>L: release

This preserves the existing behavior while preventing lost updates inside a single process.

5. Dreams UI now explains wiki-backed tabs instead of failing opaquely

Imported Insights and Memory Palace are provided by the bundled memory-wiki plugin, but the UI previously exposed those subtabs unconditionally.

This PR keeps the tabs visible, but when memory-wiki is disabled it shows a clear enablement state instead of a vague failure:

  • explains that the tabs come from memory-wiki
  • points at plugins.entries.memory-wiki.enabled = true
  • offers Open Config

It also adds better action feedback in Dreams -> Advanced for repair/dedupe:

  • confirmation before destructive-ish actions
  • inline success/error state
  • archive path surfaced after cache repair
  • Copy archive path button

Runtime Flow Summary

flowchart TD
    A["Conversation/session state"] --> B["Active-memory recall resolves strongest channel"]
    A --> C["Dreaming heartbeat consumes exact queued events once"]
    C --> D["Dream corpus built from normal session material"]
    D --> E["Dreaming-generated transcripts filtered out"]
    E --> F["Narrative diary writes serialized to DREAMS.md"]
    F --> G["Repair + dedupe available in CLI, doctor, and UI"]
    G --> H["Wiki tabs gated behind memory-wiki enablement"]

Main Files To Look At

  • extensions/active-memory/index.ts
  • src/infra/heartbeat-runner.ts
  • src/infra/system-events.ts
  • src/memory-host-sdk/host/session-files.ts
  • packages/memory-host-sdk/src/host/session-files.ts
  • extensions/memory-core/src/dreaming-phases.ts
  • extensions/memory-core/src/dreaming-repair.ts
  • extensions/memory-core/src/dreaming-narrative.ts
  • src/commands/doctor-memory-search.ts
  • src/gateway/server-methods/doctor.ts
  • ui/src/ui/controllers/dreaming.ts
  • ui/src/ui/views/dreaming.ts

Testing

  • pnpm vitest run --project infra src/infra/system-events.test.ts src/infra/heartbeat-runner.ghost-reminder.test.ts src/infra/heartbeat-runner.isolated-key-stability.test.ts
  • node scripts/run-vitest.mjs run --config vitest.config.ts extensions/memory-core/src/dreaming-repair.test.ts extensions/memory-core/src/dreaming-narrative.test.ts
  • pnpm vitest run --project extensions extensions/active-memory/config.test.ts extensions/active-memory/index.test.ts -t "modelFallback"
  • pnpm vitest run src/memory-host-sdk/host/session-files.test.ts
  • pnpm vitest run extensions/memory-core/src/dreaming-phases.test.ts
  • pnpm vitest run extensions/memory-core/src/cli.test.ts
  • pnpm vitest run src/commands/doctor-memory-search.test.ts
  • pnpm vitest run src/gateway/server-methods/doctor.test.ts
  • pnpm vitest run ui/src/ui/controllers/dreaming.test.ts
  • pnpm vitest run ui/src/ui/app-settings.test.ts
  • pnpm vitest run ui/src/ui/views/dreaming.test.ts

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • extensions/active-memory/index.ts (modified, +7/-2)
  • extensions/discord/src/monitor/native-command.options.test.ts (modified, +2/-2)
  • extensions/memory-core/api.ts (modified, +5/-1)
  • extensions/memory-core/runtime-api.ts (modified, +5/-0)
  • extensions/memory-core/src/cli.runtime.ts (modified, +97/-2)
  • extensions/memory-core/src/cli.test.ts (modified, +44/-0)
  • extensions/memory-core/src/dreaming-narrative.test.ts (modified, +143/-0)
  • extensions/memory-core/src/dreaming-narrative.ts (modified, +185/-81)
  • extensions/memory-core/src/dreaming-phases.test.ts (modified, +110/-0)
  • extensions/memory-core/src/dreaming-phases.ts (modified, +20/-0)
  • extensions/memory-core/src/dreaming-repair.test.ts (added, +128/-0)
  • extensions/memory-core/src/dreaming-repair.ts (added, +280/-0)
  • extensions/memory-core/src/memory-tool-manager-mock.ts (modified, +1/-1)
  • extensions/memory-core/src/tools.ts (modified, +10/-3)
  • extensions/telegram/src/exec-approval-resolver.test.ts (modified, +3/-2)
  • packages/memory-host-sdk/src/host/session-files.ts (modified, +29/-0)
  • src/agents/pi-hooks/context-pruning/pruner.test.ts (modified, +5/-0)
  • src/auto-reply/reply/get-reply-run.ts (modified, +10/-9)
  • src/commands/doctor-memory-search.test.ts (modified, +83/-0)
  • src/commands/doctor-memory-search.ts (modified, +61/-13)
  • src/config/schema.help.ts (modified, +1/-1)
  • src/config/zod-schema.agent-defaults.ts (modified, +6/-1)
  • src/gateway/server-methods/doctor.memory-core-runtime.ts (modified, +2/-0)
  • src/gateway/server-methods/doctor.test.ts (modified, +91/-0)
  • src/gateway/server-methods/doctor.ts (modified, +50/-1)
  • src/infra/heartbeat-runner.ghost-reminder.test.ts (modified, +54/-1)
  • src/infra/heartbeat-runner.isolated-key-stability.test.ts (modified, +2/-0)
  • src/infra/heartbeat-runner.ts (modified, +21/-1)
  • src/infra/system-events.test.ts (modified, +11/-0)
  • src/infra/system-events.ts (modified, +52/-0)
  • src/memory-host-sdk/host/session-files.test.ts (modified, +24/-0)
  • src/memory-host-sdk/host/session-files.ts (modified, +29/-0)
  • src/memory-host-sdk/runtime-files.ts (modified, +5/-1)
  • src/plugin-sdk/memory-core-bundled-runtime.ts (modified, +9/-0)
  • src/plugin-sdk/memory-core-engine-runtime.ts (modified, +10/-0)
  • ui/src/i18n/locales/en.ts (modified, +2/-0)
  • ui/src/ui/app-render.ts (modified, +38/-0)
  • ui/src/ui/app-settings.test.ts (modified, +4/-0)
  • ui/src/ui/app-view-state.ts (modified, +2/-0)
  • ui/src/ui/app.ts (modified, +2/-0)
  • ui/src/ui/controllers/dreaming.test.ts (modified, +109/-0)
  • ui/src/ui/controllers/dreaming.ts (modified, +138/-2)
  • ui/src/ui/views/dreaming.test.ts (modified, +28/-0)
  • ui/src/ui/views/dreaming.ts (modified, +97/-24)

PR #70332: fix(memory): harden dreaming diary pipeline

Description (problem / solution / changelog)

Summary

  • strip managed dream blocks even when they contain nested subheadings or legacy heading-only sections
  • turn request-scoped dream fallbacks back into diary-style prose instead of raw Reflections: fragments
  • dedupe diary entries by body so identical dream text does not repeat across days, and skip duplicate appends
  • add regression coverage for the strip, fallback, and dedupe paths

Validation

  • node scripts/test-projects.mjs extensions/memory-core/src/dreaming-phases.test.ts extensions/memory-core/src/dreaming-narrative.test.ts extensions/memory-core/src/short-term-promotion.test.ts
  • pnpm build

Changed files

  • extensions/memory-core/src/dreaming-narrative.test.ts (modified, +53/-4)
  • extensions/memory-core/src/dreaming-narrative.ts (modified, +74/-10)
  • extensions/memory-core/src/dreaming-phases.test.ts (modified, +63/-1)
  • extensions/memory-core/src/dreaming-phases.ts (modified, +21/-4)

PR #70403: fix(memory-core): keep Dream Diary to one entry per sweep

Description (problem / solution / changelog)

Summary

  • keep Dream Diary generation to one entry per nightly sweep
  • stop light and REM phases from appending their own DREAMS.md diary entries
  • update dreaming tests and docs to match deep-only diary generation

Why

A single sweep was appending multiple diary entries with the same displayed timestamp because light, REM, and deep all used the same sweep time when calling the narrative append path. This keeps the diary readable without changing phase reporting or promotion behavior.

Validation

  • pnpm test extensions/memory-core/src/dreaming-phases.test.ts extensions/memory-core/src/dreaming-narrative.test.ts
  • pnpm exec tsc -p extensions/memory-core/tsconfig.json --noEmit

Notes

  • This follows the existing dreaming-bloat cleanup work, but had to be opened from a separate fork branch because the older PR branch is owned by another fork and is not writable from this account.

Follow-up to #68774. Also builds on the earlier dreaming-bloat cleanup in #68445.

Changed files

  • docs/concepts/dreaming.md (modified, +1/-1)
  • extensions/memory-core/src/dreaming-phases.test.ts (modified, +15/-92)
  • extensions/memory-core/src/dreaming-phases.ts (modified, +1/-78)
RAW_BUFFERClick to expand / collapse

Problem Summary

The dreaming subsystem's fallback mechanism (triggered when subagent runtime is unavailable in cron/system-event context) dumps raw memory candidates into daily files alongside curated human-readable content.

This appears related to #68723 (which fixed the same issue for ), but the daily memory files remain affected.

Example Pollution

Our contains thousands of lines like:

assistant

Mixed between actual human-readable memory entries.

Impact

  • Daily memory files become unreadable (30K+ chars vs expected <5K curated content)
  • Raw candidate metadata (confidence scores, evidence paths, staging status) has no value for human recall
  • Duplicates content already stored in files
  • Makes it harder to distinguish actual memories from processing noise

Expected Behavior

Daily memory files () should contain only:

  • Curated human-readable summaries
  • Intentionally promoted memories
  • Actual conversation logs and events

Raw dreaming candidates should remain in directory only.

Environment

  • OpenClaw 2026.4.21
  • memory-core plugin with dreaming enabled (default)
  • macOS 15.x
  • Node 25.x

Suggested Fix

Apply the same filtering logic used for DREAMS.md (#68723) to daily memory file writes — skip raw candidate dumps when narrative generation falls back to request-scoped mode.

extent analysis

TL;DR

Apply the filtering logic from #68723 to daily memory file writes to prevent raw candidate dumps.

Guidance

  • Review the changes made in #68723 to understand the filtering logic applied to DREAMS.md and consider how it can be adapted for daily memory files.
  • Investigate the narrative generation fallback mechanism to determine when it switches to request-scoped mode and how this affects daily memory file writes.
  • Modify the dreaming subsystem's fallback mechanism to skip writing raw candidate dumps to daily memory files when in request-scoped mode.
  • Verify that the changes do not introduce any unintended side effects on the curated human-readable content in daily memory files.

Example

No code snippet is provided as the issue does not contain sufficient code details.

Notes

The suggested fix assumes that the filtering logic from #68723 can be directly applied to daily memory file writes. However, the actual implementation may require additional modifications to accommodate the specific requirements of daily memory files.

Recommendation

Apply the workaround by modifying the dreaming subsystem's fallback mechanism to skip raw candidate dumps, as this is the most direct approach to addressing the issue based on the provided information.

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 - ✅(Solved) Fix [Bug] Dreaming raw candidates pollute daily memory files (memory/YYYY-MM-DD.md) [4 pull requests, 1 participants]