Skip to content

fix(memos-local-openclaw): sanitize captured metadata and evidence#2

Merged
tangbotony merged 1 commit intonative_memosfrom
codex/openclaw-capture-sanitize
Mar 8, 2026
Merged

fix(memos-local-openclaw): sanitize captured metadata and evidence#2
tangbotony merged 1 commit intonative_memosfrom
codex/openclaw-capture-sanitize

Conversation

@ai-jiaqian
Copy link
Collaborator

@ai-jiaqian ai-jiaqian commented Mar 8, 2026

Description

This PR fixes memory capture sanitization issues in the local OpenClaw memos plugin.

Problem:

  • User messages with OpenClaw envelope timestamps were only sanitized when the timestamp started at column 0, so messages with leading whitespace kept the timestamp prefix in stored memory.
  • Assistant messages containing explicit [STORED_MEMORY]...[/STORED_MEMORY] evidence blocks were re-ingested verbatim, causing evidence anti-writeback failures and polluting stored memories.
  • The capture path needed to preserve ordinary mentions of the evidence tag while stripping only explicit wrapper blocks.

Changes:

  • Normalize inbound timestamp stripping so envelope prefixes are removed even when preceded by whitespace.
  • Reuse the configured evidenceWrapperTag during capture and remove explicit evidence wrapper blocks from assistant/tool text before storage.
  • Keep ordinary plain-text mentions of STORED_MEMORY unchanged.
  • Add regression coverage for timestamp sanitization and evidence anti-writeback behavior.

Relevant context:

  • No additional dependencies are required.

Related Issue (Required): N/A

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Test command run:

  • npm test -- --run tests/capture.test.ts tests/integration.test.ts

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

@tangbotony tangbotony merged commit 5547b44 into native_memos Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants