Skip to content

fix(memory): normalize auto-recall query for /new startup prompts#1228

Open
Naluko wants to merge 1 commit intoMemTensor:openclaw-local-plugin-20260324from
Naluko:fix/normalize-auto-recall-query
Open

fix(memory): normalize auto-recall query for /new startup prompts#1228
Naluko wants to merge 1 commit intoMemTensor:openclaw-local-plugin-20260324from
Naluko:fix/normalize-auto-recall-query

Conversation

@Naluko
Copy link

@Naluko Naluko commented Mar 14, 2026

Summary

Fix auto-recall failures caused by /new and /reset startup prompts being used as the recall query.

Problem

When a new session starts, the runtime may prepend a long startup prompt such as:

  • A new session was started via /new or /reset...
  • session startup instructions
  • internal runtime context
  • "Continue where you left off" text

The auto-recall pipeline was trimming some transport metadata, but it could still treat this injected startup text as the search query. That made retrieval noisy or caused it to miss relevant memories entirely.

Root Cause

Auto-recall query extraction only handled a subset of wrapper metadata inline at the call site. It did not normalize session-start prompt text introduced during /new or /reset, so the retrieval query could become the whole startup prompt instead of the user's actual message.

Fix

  • Extract query normalization into normalizeAutoRecallQuery(rawPrompt)
  • Strip sender metadata / fenced JSON wrappers
  • Reuse inbound metadata cleanup
  • Remove injected /new and /reset startup prompt text
  • Remove internal runtime context and "Continue where you left off" carry-over text
  • Use the normalized query in the auto-recall entry path

Result

Auto-recall now searches with the user's real message content instead of the session-start boilerplate, improving retrieval accuracy in fresh sessions.

@hijzy hijzy changed the base branch from main to openclaw-local-plugin-20260324 March 24, 2026 11:50
@hijzy
Copy link
Collaborator

hijzy commented Mar 24, 2026

PR Review

This PR refactors the auto-recall query normalization logic into a dedicated normalizeAutoRecallQuery() function. It systematically strips system-injected content like "/new" startup prompts, "Continue where you left off", OpenClaw runtime context blocks, and sender metadata fences before using the cleaned text as a recall query. The old logic was a simplistic "take the tail after last double newline" approach. The new implementation handles edge cases much better. The regex patterns are reasonable and the function is well-structured.

此 PR 将 auto-recall 查询的清洗逻辑重构为独立的 normalizeAutoRecallQuery() 函数,系统性地剥离 /new 启动提示、"Continue where you left off"、OpenClaw 运行时上下文、sender 元数据等系统注入内容。旧逻辑只是简单取最后双换行后的文本,新实现更全面。正则表达式合理,函数结构清晰。

  • Safety: ✅ Safe
  • Mergeable: ✅ Yes
  • Confidence: 5/5

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants