Skip to content

[Bug]:memory-core dreaming on 2026.6.1: session-corpus contains .jsonl.deleted.* paths; narrative phase writes fallback despite valid prose responses #90466

Closed as not planned

Description

@mrizzo123

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

On 2026.6.1, dreaming session-corpus files contain entries sourced from .jsonl.deleted.* session paths, and the narrative phase writes a placeholder fallback to DREAMS.md while the journal shows a full prose response on the next log line.

Steps to reproduce

  1. Install 2026.6.1 with plugins.entries.memory-core.config.dreaming.enabled: true and at least one agent.
  2. Let dreaming run for 2–3 cycles (default cron 0 7 * * *).
  3. Run: grep -c '\.deleted\.' ~/.openclaw/workspace/memory/.dreams/session-corpus/*.txt
    Observe non-zero counts.
  4. Run: openclaw memory rem-harness --agent main --json --grounded and observe deep candidates whose path field references .jsonl.deleted.* files.
  5. Watch the gateway journal during a 0 7 * * * cycle. For each affected phase, the plugin logs narrative generation produced no text for <phase> phase; writing fallback diary entry, immediately followed by a separate stdout line containing a complete prose response.
  6. Inspect DREAMS.md for the affected workspace; entries read A memory trace surfaced, but details were unavailable in this run.

Expected behavior

Per 2026.5.28 behavior (last known working version): dreaming narrative phase writes prose entries to DREAMS.md derived from the model's response, and session-corpus does not contain entries sourced from session files with .jsonl.deleted.* path suffixes.

Actual behavior

  • session-corpus/*.txt files contain entries with path prefix [<agent>/sessions/<agent>/<uuid>.jsonl.deleted.<timestamp>#L<n>].
  • On a 5-agent install, the main agent's corpus contained 411 of 570 lines (~72%) matching this pattern across 15 daily files; some days were 100% these paths.
  • openclaw memory rem-harness --agent main --json --grounded returned 507 deep candidates whose snippets are sourced from .jsonl.deleted.* paths.
  • During each dreaming cycle, the gateway journal logs narrative generation produced no text for <phase> phase; writing fallback diary entry. The next stdout line contains a complete prose response, indicating the model returned text that the plugin classified as empty.
  • DREAMS.md entries for affected phases are the placeholder string A memory trace surfaced, but details were unavailable in this run.

OpenClaw version

2026.6.1 (commit 2e08f0f)

Operating system

Ubuntu 24.04 (x86_64)

Install method

npm global (/usr/lib/node_modules/openclaw)

Model

openrouter/x-ai/grok-4.3 (default dreaming model); anthropic/claude-sonnet-4-6 (deep-phase override). "produced no text" classification observed against both per journal output.

Provider / routing chain

openclaw → openrouter (default and rem/light phases) and openclaw → anthropic (deep phase). Memory-core narrative subagent runs use the same routing.

Additional provider/model setup details

Memory plugin: bundled memory-core. dreaming.enabled: true at all five agents/workspaces. The "produced no text" classification reproduces across model providers per journal observation; the symptom is not provider-specific.

Logs, screenshots, and evidence

Contamination count, main agent corpus (2026-06-04):

  2026-05-26.txt  contam=38   total=38
  2026-05-28.txt  contam=39   total=39
  2026-05-31.txt  contam=40   total=50
  2026-06-01.txt  contam=40   total=47
  2026-06-02.txt  contam=35   total=43
  2026-06-03.txt  contam=10   total=10
  (15 files total; 3 days clean, 12 contaminated, ~411/570 lines)

rem-harness candidate sample (one of 507):

  "snippet": "User: Write a dream diary entry from these memory fragments: -
              Assistant: <truncated session content> ..."
  "path":    "memory/.dreams/session-corpus/2026-06-01.txt"

Journal excerpt from a dreaming cycle on 2026-06-04 07:00 UTC:

  07:00:14 [plugins] memory-core: narrative generation produced no text for deep phase; writing fallback diary entry.
  07:00:14 [plugins] memory-core: narrative generation used fallback for deep phase because the narrative run produced no text.
  07:00:14 <complete prose response captured on next stdout line>

Impact and severity

Affected users/systems/channels: Users with memory-core.config.dreaming.enabled: true, especially multi-agent installs.
Severity: Medium-high. Memory promotion candidates and DREAMS.md fill with content sourced from prior dreaming cycles; long-term memory quality degrades indirectly.
Frequency: Always (100% of dreaming cycles on 2026.6.1 with multiple agents enabled).
Consequence: Long-term memory consolidation silently degrades. The fallback prose mechanism means dreaming never visibly fails; operators may not detect the issue until inspecting DREAMS.md.

Additional information

Last known good: 2026.5.28.
First known bad: 2026.6.1 (intermediate 2026.6.x builds not tested).
Related: #65653 (narrative-subagent sessions write under agents/main/sessions/ regardless of source agent).
2026.6.2-beta.1 release notes do not appear to address this; memory items in that release cover watcher pressure and session write-lock release on prompt-cache fence reads.

Workaround applied:
find /memory/.dreams/session-corpus -name '*.txt' -exec sed -i '/.deleted./d' {} ;
mv /memory/.dreams/short-term-recall.json /
openclaw config set 'plugins.entries.memory-core.config.dreaming.enabled' false --strict-json
systemctl --user restart openclaw-gateway

openclaw memory rem-backfill --rollback and --rollback-short-term per agent both returned removedEntries: 0 / removedShortTermEntries: 0. These commands only undo manual rem-backfill operations and do not affect automatic session ingestion into session-corpus.

Activity

  1. clawsweeper commented on Jun 4, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

    Close as superseded: the useful remaining work from this umbrella report is now split across focused open issues for the archive-corpus defect and the remaining narrative fallback variants, while the already-merged retry PR covers the immediate post-run read visibility race.

    Canonical path: #90313 is open and specifically tracks the usage-counted archive predicate plus cron-descended subagent classification gaps that explain .jsonl.deleted.* and .jsonl.reset.* corpus contamination.

    So I’m closing this here and keeping the remaining discussion on #90313, #87182, #90292, and #90781.

    Review details

    Best possible solution:

    Keep this umbrella closed and route fixes through the focused canonical issues so archive ingestion, cleanup/readback races, and diagnostic fallback behavior can be resolved independently without losing this report’s linked evidence.

    Do we have a high-confidence way to reproduce the issue?

    Yes, source-level: current main still has an archive-eligible session listing feeding dreaming, and the narrative path still falls back when settled reads remain empty. I did not run a live current-main dreaming cron sweep in this read-only review.

    Is this the best way to solve the issue?

    Yes. Closing this umbrella as superseded is the best cleanup path because the remaining work is already split into narrower open reports with fresher evidence and clearer fix boundaries.

    Security review:

    Security review: This is issue cleanup with no patch security surface to review.

    AGENTS.md: found and applied where relevant.

    What I checked:

    Likely related people:

    • bennewell35: Authored the merged memory-core retry PR that covers the immediate post-run narrative message visibility race in this issue cluster. (role: recent narrative fix author; confidence: high; commits: cdb55b3edb37; files: extensions/memory-core/src/dreaming-narrative.ts, extensions/memory-core/src/dreaming-narrative.test.ts)
    • vincentkoc: Merged PR 89091 and posted maintainer verification that the bounded settle loop observes delayed assistant text before fallback. (role: merger and verifier; confidence: high; commits: cdb55b3edb37; files: extensions/memory-core/src/dreaming-narrative.ts, extensions/memory-core/src/dreaming-narrative.test.ts)
    • vignesh07: Authored the session-transcript dreaming corpus feature history that introduced the central corpus ingestion surface. (role: feature-history contributor; confidence: medium; commits: 338c7b8d6672, 5291a2cfd1be; files: extensions/memory-core/src/dreaming-phases.ts, extensions/memory-core/src/dreaming-phases.test.ts)
    • jalehman: Authored and merged the session-store based skip for dreaming transcript ingestion, an adjacent filter in the same corpus path. (role: adjacent corpus filter contributor; confidence: medium; commits: a1b01f0281d0; files: extensions/memory-core/src/dreaming-phases.ts, packages/memory-host-sdk/src/host/session-files.ts)
    • zqchris: Authored the inbound metadata stripping work in the session-corpus host helper used by memory-core dreaming. (role: adjacent session-corpus contributor; confidence: medium; commits: 82e349a48ad9; files: packages/memory-host-sdk/src/host/session-files.ts)

    Codex review notes: model internal, reasoning high; reviewed against d1b33a6040a4.

  2. added
    P2Normal backlog priority with limited blast radius.
    impact:data-lossCan lose, corrupt, or silently drop user/session/config data.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    on Jun 4, 2026
  3. apalmiere commented on Jun 5, 2026

    @apalmiere

    Root cause for the "narrative phase writes fallback despite valid prose" half of this issue (the produced no text path), traced on 2026.6.1 in dist/dreaming-narrative-*.js (generateAndAppendDreamNarrative).

    Mechanism: the readback reads the wrong session key.

    The narrator subagent run succeeds (result.status === "ok"), so the model does return prose — which is why the very next journal line shows a complete response. But the readback that follows uses the bare attempt key, while the run stored its messages under the owner-canonical key (agent:<id>:<bareKey>):

    if (!successfulSessionKey) return;
    const { messages } = await params.subagent.getSessionMessages({
        sessionKey: successfulSessionKey,   // <-- bare key e.g. "dreaming-narrative-deep-<hash>"
        limit: 5
    });
    const narrative = extractNarrativeText(messages);
    if (!narrative) {
        // logs "produced no text", writes fallback  <-- always taken

    successfulSessionKey comes from buildNarrativeAttemptSessionKey(buildNarrativeSessionKey(...)), which yields an unprefixed dreaming-narrative-<phase>-<hash>. But getSessionMessages → gateway sessions.get resolves/stores under the owner-canonical key via resolveSessionStoreKey (session-store-key-*.js), i.e. agent:<id>:dreaming-narrative-<phase>-<hash>. The bare-key sessions.get misses → messages empty → extractNarrativeText returns nothing → unconditional fallback. The prose is generated and then discarded every cycle.

    Confirmed locally: zero diary/narrator readback hits, produced no text on every phase, DREAMS.md filled with raw fallback stubs — while gateway logs showed full Sonnet prose on the adjacent line. Last good prose entry predates the regression.

    Fix: when the bare-key readback is empty, retry against the owner-canonical key(s) before falling back. Minimal, reuses existing runtime resolvers (listAgentIds / canonicalizeSessionKeyForAgent):

    let { messages } = await params.subagent.getSessionMessages({ sessionKey: successfulSessionKey, limit: 5 });
    let narrative = extractNarrativeText(messages);
    if (!narrative && !/^agent:[^:]+:/.test(successfulSessionKey)) {
        let agentIds = ["main"];
        try {
            const cfg = getRuntimeConfig?.()?.config ?? getRuntimeConfig?.();
            const ids = cfg ? listAgentIds(cfg) : null;
            if (Array.isArray(ids) && ids.length) agentIds = ids;
        } catch {}
        for (const aid of agentIds) {
            const retry = await params.subagent.getSessionMessages({ sessionKey: `agent:${aid}:${successfulSessionKey}`, limit: 5 });
            const text = extractNarrativeText(retry.messages);
            if (text) { messages = retry.messages; narrative = text; break; }
        }
    }

    The cleaner upstream fix is to canonicalize the key once at the source (have generateAndAppendDreamNarrative resolve successfulSessionKey through the same resolveSessionStoreKey path the writer uses, or have the narrator return its run output directly rather than via a session readback), so the read and write keys can never diverge.

    The .jsonl.deleted.* corpus-path half of this issue looks separate (session-corpus sourcing from soft-deleted session files); I haven't root-caused that one, but it's plausibly why some readbacks land on a now-renamed/deleted store entry, compounding the miss.

    Happy to open a PR for the readback fix if useful.

  4. mrizzo123 commented on Jun 5, 2026

    @mrizzo123
    Author

    @apalmiere thanks for this, the key-mismatch finding lines up exactly with what we observed (full prose on the adjacent journal line, but DREAMS.md getting the fallback string). Please open the PR, happy to test on our install once it lands in any tagged release (beta or stable).

    One clarification to make sure I'm reading you right: your fix addresses the "produced no text" / wrong-readback-key bug. The .jsonl.deleted.* paths showing up in session-corpus/*.txt look like a separate issue (autoingestion of soft-deleted session files), which I assume needs its own fix. Is that your read too?

    If so, want me to split that half into a sibling issue so #90466 stays focused on the readback fix you're patching?

  5. tianxiaochannel-oss88 commented on Jun 8, 2026

    @tianxiaochannel-oss88
    Contributor

    Adding another live datapoint for the DREAMS.md fallback half of this issue.

    Environment:

    • OpenClaw 2026.6.1 (2e08f0f)
    • macOS 26.5.1, arm64
    • bundled memory-core plugin, dreaming enabled

    Observed locally:

    • ~/.openclaw/workspace/DREAMS.md contains the exact placeholder string A memory trace surfaced, but details were unavailable in this run. 5 times across the June 6-8 diary window.
    • The June 8 gateway log shows the same narrative no-text path for all phases:
      • /tmp/openclaw/openclaw-2026-06-08.log: 8 lines matching narrative generation produced no text / narrative generation used fallback
      • examples include deep, rem, and light phases at the 03:00 local dreaming run.
    • June 7 also shows the same pattern (/tmp/openclaw/openclaw-2026-06-07.1.log: 6 matching lines).

    Source-level observation from the installed package:

    function buildRequestScopedFallbackNarrative(data) {
      return data.snippets.map((value) => value.trim()).find((value) => value.length > 0)
        ?? (data.promotions ?? []).map((value) => value.trim()).find((value) => value.length > 0)
        ?? "A memory trace surfaced, but details were unavailable in this run.";
    }

    In my local install this is in the bundled dist/dreaming-narrative-*.js; the fallback is not coming from local workspace docs/scripts/overlays. That lines up with this issue being in the native memory-core dreaming narrative path rather than a user-authored memory framework artifact.

    This also matches the comment above about the generated prose being discarded or read back as empty: the log says the narrative run produced no text, while DREAMS.md receives the generic fallback placeholder instead of a real diary entry.

  6. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingclawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions