openclaw - ✅(Solved) Fix feat(memory): graduate sessionMemory from experimental — solve the multi-session continuity problem [1 pull requests, 1 comments, 2 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#51386Fetched 2026-04-08 01:11:55
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×3commented ×1

Root Cause

Multi-channel continuity is the most important UX problem for a personal assistant. Users don't think in terms of "sessions" — they think they're talking to one entity. Every time the agent fails to remember something from another channel, trust erodes. The code is ready. This is a policy and documentation decision.

Fix Action

Fixed

PR fix notes

PR #51341: feat(memory): enable smart memory defaults for all new installations

Description (problem / solution / changelog)

Problem

New OpenClaw users encounter a frustrating "twin sessions" problem: the agent on webchat and the agent on Telegram feel like two separate people who don't share memory. The features to fix this already exist in the codebase — session memory indexing, temporal decay, and MMR re-ranking — but they are all opt-in and require manual openclaw.json configuration that most users never discover.

Solution

Add applyMemorySearchDefaults() to the config pipeline, following the exact same pattern as applyContextPruningDefaults() and applyCompactionDefaults(). This enables three existing platform features automatically for new installations:

1. Session memory indexing

{ "experimental": { "sessionMemory": true }, "sources": ["memory", "sessions"] }

Every conversation across all channels is automatically indexed. memory_search from webchat can find context from a Telegram conversation and vice versa — no manual memory file writing required.

2. Temporal decay (halfLifeDays: 30)

Recent memories rank higher automatically. A note from yesterday beats a semantically stronger but 6-month-old note on the same topic. Scores halve every 30 days for dated daily files; evergreen files (MEMORY.md, topic files) are never decayed.

3. MMR re-ranking (lambda: 0.7)

Avoids returning near-duplicate snippets. The agent gets diverse, complementary results instead of the same daily note repeated five times with slightly different wording.

Design decisions

  • Opt-out, not opt-in: applyMemorySearchDefaults() is a no-op if memorySearch is already defined in config. Existing users are completely unaffected.
  • Platform layer, not prose: The guarantee lives in code, not in SOUL.md or AGENTS.md instructions. No agent discipline required, no silent failure modes.
  • Conservative values: All defaults match the values recommended in the existing docs (vectorWeight: 0.7, halfLifeDays: 30, lambda: 0.7).
  • Same pipeline pattern: Wired into io.ts in the same apply* chain as all other defaults.

Files changed

  • src/config/defaults.ts — adds applyMemorySearchDefaults()
  • src/config/io.ts — wires it into both config load paths
  • src/config/config.memory-search-defaults.test.ts — new test file

Testing

✓ enables session memory indexing, temporal decay, and MMR by default
✓ does not overwrite explicit memorySearch config

Relationship to existing work

This PR does not implement any new features. It only changes the default state of features that Vignesh and the memory team already built and documented. The heavy lifting is already done — this is just flipping the right switches for new users.

Changed files

RAW_BUFFERClick to expand / collapse

Problem

When a user talks to their agent on webchat and switches to Telegram, the agent on Telegram has no knowledge of the webchat conversation. It feels like two separate people — "twin brothers who don't share memory."

The fix already exists: experimental.sessionMemory, which automatically indexes all session transcripts so memory_search can find context from any channel. It was added in January 2026 and has been heavily developed since. But it's still experimental, so the vast majority of users never discover it.

What's Already Built and Working

Based on the current codebase, the following is already implemented:

Session file indexing (src/memory/session-files.ts):

  • Parses JSONL session files, extracts User/Assistant turns, normalizes whitespace
  • Indexes as chunks alongside regular memory files

Delta thresholds (already tuned):

  • Only reindexes when a session grows by 100KB or 50 JSONL messages
  • Runs in background, never blocks search

Post-compaction sync:

  • sync.sessions.postCompactionForce is already wired into the compaction runner
  • After each compaction, session memory sync is forced — so compacted sessions stay indexed

Privacy/scope control:

  • The QMD scope system supports per-channel scoping via chatType, keyPrefix, rawKeyPrefix
  • Group chats can be excluded from indexing by policy — the infrastructure is there

QMD backend support:

  • When memory.backend = "qmd", session transcripts are exported to a dedicated QMD collection
  • Both backends support session memory

What Was Fixed (Stability Evidence)

The session memory feature received multiple bug fixes since launch:

  • fix: session-memory hook finds previous session file after /new/reset
  • Revert "fix: session-memory hook finds previous session file after /new/reset" (revert + re-fix)
  • fix(session-memory): harden reset transcript recovery
  • fix(session-memory): fallback to rotated transcript after /new
  • Hooks: persist session memory on /reset

This is 5 commits addressing the same edge case (orphaned/missed transcripts after /reset and /new). The question for maintainers: is this edge case now fully stable, or are there known remaining gaps?

Open Known Issue

  • #47023 — mcporter path for QMD on Linux still falls back to raw qmd subprocess (not using MCP keep-alive runtime). This affects QMD-backed session memory performance on Linux.

Proposal

Graduate sessionMemory from experimental to stable, with these steps:

Step 1: Confirm stability

  • Are there remaining known edge cases after /reset, /new, or session rotation?
  • Has delta-threshold tuning (100KB / 50 messages) been validated against real user data?

Step 2: Privacy defaults

  • Default scope: DM-only (don't index group chat transcripts). The scope system already supports this.
  • Document clearly that session transcripts are indexed and how to opt out per-channel.

Step 3: Default-on for new installs

  • Add to applyMemorySearchDefaults() once the above are confirmed
  • Document in docs/concepts/memory.md under "What's enabled by default"

Step 4: Cost guidance

  • For paid embedding API users, estimate the token cost of session indexing at average usage
  • Add to docs so users can make an informed decision before enabling on existing installs

Why This Matters

Multi-channel continuity is the most important UX problem for a personal assistant. Users don't think in terms of "sessions" — they think they're talking to one entity. Every time the agent fails to remember something from another channel, trust erodes. The code is ready. This is a policy and documentation decision.

Related

  • #51385 — Human-like memory lifecycle (frequency, impact, forgetting, consolidation)

extent analysis

Fix Plan

To graduate sessionMemory from experimental to stable, follow these steps:

  • Step 1: Confirm stability
    • Review the codebase for any remaining known edge cases after /reset, /new, or session rotation.
    • Validate delta-threshold tuning (100KB / 50 messages) against real user data.
  • Step 2: Privacy defaults
    • Set the default scope to DM-only (don't index group chat transcripts) by updating the chatType and keyPrefix in src/memory/session-files.ts.
    • Document clearly that session transcripts are indexed and how to opt out per-channel in docs/concepts/memory.md.
  • Step 3: Default-on for new installs
    • Add sessionMemory to applyMemorySearchDefaults() in src/memory/search.ts.
    • Document the change in docs/concepts/memory.md under "What's enabled by default".
  • Step 4: Cost guidance
    • Estimate the token cost of session indexing at average usage and add to docs/concepts/memory.md.
    • Provide guidance on how to estimate costs for existing installs.

Example code changes:

// src/memory/session-files.ts
const defaultScope = {
  chatType: 'dm',
  keyPrefix: 'session-memory',
};

// src/memory/search.ts
function applyMemorySearchDefaults() {
  // ...
  sessionMemory: true,
  // ...
}

Verification

To verify that the fix worked, test the following scenarios:

  • A user switches from webchat to Telegram and the agent remembers the conversation.
  • A user resets the conversation and the agent still remembers the previous conversation.
  • A user creates a new conversation and the agent does not remember the previous conversation.

Extra Tips

  • Monitor user feedback and adjust the delta-threshold tuning as needed.
  • Consider implementing a forgetfulness mechanism to remove old session transcripts and reduce storage costs.
  • Review the related issue #51385 for implementing a human-like memory lifecycle.

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