openclaw - 💡(How to fix) Fix Memory Dreaming: Light sleep sort prioritizes recency over recallCount, hiding real recall data [2 comments, 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#71976Fetched 2026-04-27 05:36:38
View on GitHub
Comments
2
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
commented ×2cross-referenced ×1

Root Cause

The light dreaming phase sorts entries by lastRecalledAt DESC first, then ecallCount DESC. Because ingestDailyMemorySignals and ingestSessionTranscriptSignals refresh lastRecalledAt daily for all entries (with signalType: "daily"), the daily-injected entries always appear first. Real recall entries (recallCount=3) get buried at positions 300-5000+. With the default limit of 100, the light sleep report always shows ecalls: 0.

RAW_BUFFERClick to expand / collapse

Bug 1: Light dreaming sort order (dreaming-Dmn9KbNB.js)

The light dreaming phase sorts entries by lastRecalledAt DESC first, then ecallCount DESC. Because ingestDailyMemorySignals and ingestSessionTranscriptSignals refresh lastRecalledAt daily for all entries (with signalType: "daily"), the daily-injected entries always appear first. Real recall entries (recallCount=3) get buried at positions 300-5000+. With the default limit of 100, the light sleep report always shows ecalls: 0.

Current: n.toSorted((a, b) => { const byTime = Date.parse(b.lastRecalledAt) - Date.parse(a.lastRecalledAt); if (byTime !== 0) return byTime; return b.recallCount - a.recallCount; }) n Fix: n.toSorted((a, b) => { const byRecall = b.recallCount - a.recallCount; if (byRecall !== 0) return byRecall; return Date.parse(b.lastRecalledAt) - Date.parse(a.lastRecalledAt); }) n

Bug 2: Rehydration search span too narrow (short-term-promotion-Cd3cMDbx.js)

elocateCandidateRange uses Math.max(preferredSpan + 3, 8) which is too narrow for broad recall entries (20-30 lines). When daily memory files grow, stored line ranges shift and rehydration fails.

Fix: Math.max(preferredSpan + 15, 20)`n

Impact

Both bugs cause promoted results even when valid candidates exist in short-term-recall.json with recallCount >= 3, uniqueQueries >= 3, and score >= 0.80.

extent analysis

TL;DR

To fix the issues, update the sorting logic to prioritize recall count over last recalled time and increase the rehydration search span.

Guidance

  • Update the sorting function to prioritize recall count, as shown in the provided fix: n.toSorted((a, b) => { const byRecall = b.recallCount - a.recallCount; if (byRecall !== 0) return byRecall; return Date.parse(b.lastRecalledAt) - Date.parse(a.lastRecalledAt); })
  • Increase the rehydration search span by using Math.max(preferredSpan + 15, 20) instead of Math.max(preferredSpan + 3, 8)
  • Verify the fixes by checking the light sleep report and ensuring that real recall entries are no longer buried and promoted results are accurate
  • Test the updated code with various input scenarios to ensure the fixes do not introduce new issues

Example

// Updated sorting function
n.toSorted((a, b) => {
  const byRecall = b.recallCount - a.recallCount;
  if (byRecall !== 0) return byRecall;
  return Date.parse(b.lastRecalledAt) - Date.parse(a.lastRecalledAt);
});

// Updated rehydration search span
const searchSpan = Math.max(preferredSpan + 15, 20);

Notes

The provided fixes assume that the recall count and last recalled time are the primary factors in determining the sorting order. Additional testing may be necessary to ensure that these fixes do not introduce new issues or affect other parts of the system.

Recommendation

Apply the workarounds, as they directly address the identified issues and provide a clear solution. The updated sorting function and increased rehydration search span should improve the accuracy of promoted results and the light sleep report.

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 Memory Dreaming: Light sleep sort prioritizes recency over recallCount, hiding real recall data [2 comments, 1 participants]