Skip to content

OpenClaw plugin: fix auto-recall injection and auto-capture message drop#4065

Merged
deshraj merged 2 commits intomem0ai:mainfrom
jamesjmartin:fix/openclaw-recall-capture-cla
Feb 17, 2026
Merged

OpenClaw plugin: fix auto-recall injection and auto-capture message drop#4065
deshraj merged 2 commits intomem0ai:mainfrom
jamesjmartin:fix/openclaw-recall-capture-cla

Conversation

@Zlo7
Copy link
Copy Markdown
Contributor

@Zlo7 Zlo7 commented Feb 17, 2026

Fix OpenClaw auto-capture dropping valid user text when recall context is prepended, and include the prior recall injection key fix in the same patch set.

Description

This PR consolidates two related OpenClaw plugin bug fixes in openclaw/index.ts:

  1. Auto-recall injection fix
    before_agent_start now returns { prependContext: ... } (not systemContext) so recalled memories are actually injected into prompts.

  2. Auto-capture preservation fix
    In agent_end, messages containing <relevant-memories>...</relevant-memories> are no longer skipped wholesale.
    Instead, injected recall context is stripped and the remaining real user/assistant text is captured if non-empty.

Root Cause #1: Hook return property mismatch (systemContext vs prependContext)
Impact #1: Auto-recall looked successful in logs but memories never reached the LLM

Root Cause #2: Marker-based hard skip in capture path
Impact #2: Valid user content was silently dropped whenever injected recall block was present

Fix #1: Rename systemContextprependContext
Fix #2: Replace skip-on-marker with strip-and-keep behavior; skip only empty leftovers

Fixes #4037
Fixes #4063

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Manual testing steps performed:

  • Set OPENCLAW_CACHE_TRACE and OPENCLAW_ANTHROPIC_PAYLOAD_LOG to true
  • Enabled auto-recall and auto-capture in mem0 OpenClaw plugin
  • Restarted openclaw gateway
  • Started conversation that triggers memory recall
  • Verified <relevant-memories> appears in effective prompt logs
  • Verified capture no longer drops entire message when recall block is present
  • Verified only injected block is removed and remaining user text is preserved/captured
  • Verified system prompt (agent.md, soul.md) remains unaffected

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Zlo7 added 2 commits February 17, 2026 07:23
Change systemContext to prependContext in before_agent_start hook to match OpenClaw's expected property name. Memories were being fetched but never injected into prompts.
…nded

Strip injected <relevant-memories> blocks instead of dropping entire messages, and accept any content block with string text during auto-capture parsing.
@deshraj
Copy link
Copy Markdown
Collaborator

deshraj commented Feb 17, 2026

Thanks for fixing this @Zlo7.

@deshraj deshraj merged commit a681081 into mem0ai:main Feb 17, 2026
1 of 2 checks passed
@deshraj
Copy link
Copy Markdown
Collaborator

deshraj commented Feb 17, 2026

jamebobob pushed a commit to jamebobob/mem0-vigil-recall that referenced this pull request Mar 29, 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

2 participants