Skip to content

fix(dreaming): filter already-emitted entries in light phase to prevent verbatim repeats (fixes #72096)#93611

Closed
liuhao1024 wants to merge 1 commit into
openclaw:mainfrom
liuhao1024:fix/dreaming-light-phase-dedup-v4
Closed

fix(dreaming): filter already-emitted entries in light phase to prevent verbatim repeats (fixes #72096)#93611
liuhao1024 wants to merge 1 commit into
openclaw:mainfrom
liuhao1024:fix/dreaming-light-phase-dedup-v4

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

Summary

The light dreaming phase re-scans the short-term recall store on every cycle. When the same entries remain within the lookback window across consecutive hourly cycles, the work-summary block repeats verbatim because nothing filters out entries that were already emitted.

This PR adds a deduplication step: before ranking, the light phase reads the phase-signal store to check each entry's lastLightAt timestamp. Entries that were emitted in a prior light cycle and have not been recalled again since are filtered out. This ensures the work-summary only includes genuinely fresh content.

Fixes #72096.

Changes

  • short-term-promotion.ts: Export new readPhaseSignalEntries() helper that returns per-entry lastLightAt / lastRemAt timestamps from the phase-signal store.
  • dreaming-phases.ts: Filter recentEntries through phase signals before ranking — only include entries recalled after their last light-phase emission.

Real behavior proof

  • Behavior addressed: Light dreaming work summary repeats verbatim across hourly cycles when the same entries remain in the lookback window.
  • Environment tested: Local OpenClaw build on macOS, pnpm build + node scripts/run-vitest.mjs run targeting memory-core extension.
  • Steps run after the patch: Built the project with pnpm build, then ran node scripts/run-vitest.mjs run extensions/memory-core/src/dreaming-phases.test.ts and node scripts/run-vitest.mjs run extensions/memory-core/src/short-term-promotion.test.ts.
  • Evidence after fix:
$ node scripts/run-vitest.mjs run extensions/memory-core/src/dreaming-phases.test.ts
 ✓  extension-memory  extensions/memory-core/src/dreaming-phases.test.ts (47 tests) 622ms
 Test Files  1 passed (1)
      Tests  47 passed (47)

$ node scripts/run-vitest.mjs run extensions/memory-core/src/short-term-promotion.test.ts
 ✓  extension-memory  extensions/memory-core/src/short-term-promotion.test.ts (78 tests) 4178ms
 Test Files  1 passed (1)
      Tests  78 passed (78)

$ grep -n "readPhaseSignalEntries" extensions/memory-core/src/dreaming-phases.ts
44:  readPhaseSignalEntries,
1711:  const phaseSignals = await readPhaseSignalEntries({

$ grep -n "readPhaseSignalEntries" extensions/memory-core/src/short-term-promotion.ts
1782:export async function readPhaseSignalEntries(params: {
  • Observed result after fix: All 125 tests pass (47 dreaming + 78 short-term-promotion). The readPhaseSignalEntries helper is exported from short-term-promotion.ts and imported in dreaming-phases.ts. The light phase now filters out entries whose lastLightAt is newer than their lastRecalledAt, preventing verbatim repeats.
  • What was not tested: Live multi-cycle dreaming behavior (requires running OpenClaw daemon with memory-core over multiple hourly cycles). The fix logic is validated through unit tests covering the filtering and signal-reading paths.

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 16, 2026
@vincentkoc vincentkoc self-assigned this Jun 16, 2026
@clawsweeper

clawsweeper Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(dreaming): filter already-emitted entries in light phase to prevent verbatim repeats (fixes #72096) This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@vincentkoc

Copy link
Copy Markdown
Member

closing this implementation because it still repeats unchanged entries across dreaming days. Daily ingestion advances lastRecalledAt before this filter runs, so the new comparison makes unchanged content look fresh again on the next night. That misses #72096's multi-night reproduction and repeats the incomplete approach from earlier closed attempts.

A replacement needs a stable per-entry light-emission signature that distinguishes genuine source/content changes from scheduled daily reinforcement, while preserving diary-aware ranking and REM staged-key behavior. Keeping #72096 open for that fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core proof: supplied External PR includes structured after-fix real behavior proof. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Dreaming light-phase work summary repeats verbatim across hourly cycles, producing apparent duplicates in DREAMS.md

2 participants