Skip to content

Bug: /new can leak prior-session memoryReflection context into the next session #718

@locolyric

Description

@locolyric

Summary

After upgrading OpenClaw to the latest version, using /new in Telegram direct chats can cause the assistant to continue replying to the previous conversation instead of starting a clean new session.

This started only after the latest OpenClaw update. The current suspicion is that memoryReflection state is being generated on command:new and then injected back into the next session through before_prompt_build, especially when injectMode is set to inheritance+derived.

Environment

  • OpenClaw: 2026.4.26
  • Channel: Telegram direct chat
  • memory-lancedb-pro: 1.1.0-beta.10
  • Plugin build tag seen in logs: memory-lancedb-pro-diag-20260308-0058
  • Config:
    • smartExtraction: true
    • sessionStrategy: "memoryReflection"
    • memoryReflection.injectMode: "inheritance+derived"

Observed behavior

After /new, the next user message may still receive a reply that continues or references the previous conversation, as if the new session inherited too much execution context.

This is not just broad long-term memory recall. It behaves more like previous-session reflection/derived context is being re-injected into the fresh session.

Expected behavior

After /new, the next session should be clean at the conversation level.
Long-term memory or stable behavioral rules may still be available, but the assistant should not continue the previous session's active reply context.

Reproduction pattern

  1. Use OpenClaw with memory-lancedb-pro enabled.
  2. Configure:
    • sessionStrategy: "memoryReflection"
    • memoryReflection.injectMode: "inheritance+derived"
  3. Chat with the assistant in Telegram direct chat.
  4. Send /new.
  5. Send a new message on a different topic.
  6. Observe that the assistant may still respond as if it is continuing the previous conversation.

Relevant findings

  • The plugin registers these hooks in the current setup:
    • command:new
    • command:reset
    • before_prompt_build
    • after_tool_call
    • session_end
  • The current implementation appears to do this sequence:
    1. /new triggers runMemoryReflection
    2. reflection/derived slices are generated from the previous session
    3. the next session's before_prompt_build injects inherited and/or derived reflection context back into the prompt
  • This makes it plausible that prior-session derived context leaks across the /new boundary.

Why this looks like a regression

This issue only started after updating OpenClaw to the latest version.
That suggests an integration regression around hook migration / prompt-build timing / session reset boundaries, rather than a long-standing memory configuration issue.

Suspected root cause

A session-boundary leak between:

  • command:new reflection generation for the previous session
  • before_prompt_build reflection injection for the next session

Possibly one of these:

  1. newly generated derived reflection is immediately eligible for injection into the fresh session
  2. session-specific cached derived state is not cleared strictly enough across /new
  3. the new session still resolves previous-session reflection data too aggressively when injectMode = inheritance+derived

Suggested direction

Potential fixes could include one or more of:

  • do not inject derived reflection into the first turn after /new
  • limit /new carryover to stable inheritance only
  • make derived reflection strictly session-local and never eligible for the next fresh session
  • add an explicit guard so command:new output from the just-closed session cannot re-enter the immediately opened session as active prompt context

Notes

I have not yet reduced this to a minimal standalone test case in code, but the configuration, hook registration, and behavior are consistent with a memoryReflection cross-session leakage bug triggered by /new on the latest OpenClaw.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions