#15896: fix(memory-lancedb): capture even with injected recall context
extensions: memory-lancedb
stale
size: XS
## Problem\nWhen `autoRecall` is enabled, the plugin prepends a `<relevant-memories>…</relevant-memories>` block into the prompt. OpenClaw persists the *full* prompt string in the message list, so the user message text contained `<relevant-memories>` and auto-capture would silently skip it (`shouldCapture` returned false).\n\nNet: users could tell an agent "remember X" and the agent would reply "Saved", but nothing durable would be written to LanceDB unless the agent explicitly called `memory_store`.\n\n## Fix\n- Strip the injected `<relevant-memories>…</relevant-memories>` block before evaluating capture heuristics and before storing text.\n- Update tests to reflect that an injected prefix should not prevent capture.\n\n## Notes\n- Adds `@lancedb/lancedb-darwin-arm64` as an optional dependency so LanceDB loads cleanly on Apple Silicon macOS runners.\n\n## Tests\n- `pnpm vitest run extensions/memory-lancedb/index.test.ts`
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Fixed auto-capture to work correctly when `autoRecall` is enabled. Previously, the injected `<relevant-memories>` context block prevented any message from being captured to LanceDB, even when the message contained explicit "remember" requests.
The fix strips the injected recall context before evaluating capture heuristics and before storing text, ensuring the actual user content is preserved while the ephemeral context is removed.
- Extracted `stripRelevantMemoriesBlock()` helper that removes injected `<relevant-memories>` blocks using non-greedy regex matching
- Removed the blanket rejection of text containing `<relevant-memories>` from `shouldCapture()`
- Applied sanitization in the capture flow (line 575-577) before filtering and storage
- Updated tests to verify that injected prefixes are stripped correctly
- Added `@lancedb/lancedb-darwin-arm64` as optional dependency for Apple Silicon macOS CI runners
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The fix is well-targeted and addresses a specific bug without changing broader system behavior. The regex pattern for stripping context is correct (non-greedy matching prevents over-removal), sanitization happens before both validation and storage (preventing contaminated data), and tests verify the new behavior. The optional dependency addition is appropriate for CI infrastructure.
- No files require special attention
<sub>Last reviewed commit: e8e9977</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#3401: fix(memory-lancedb): improve autoCapture with turn-by-turn processing
by mike-nott · 2026-01-28
88.7%
#11113: fix(memory-lancedb): preserve error cause in LanceDB load failure
by marezgui · 2026-02-07
76.7%
#22692: fix(memory-lancedb): [P1] add missing runtime deps — plugin broken ...
by mahsumaktas · 2026-02-21
76.0%
#20241: fix(memory-lancedb): consolidate preference keyword/category detect...
by ciberponk · 2026-02-18
75.9%
#17566: memory-lancedb: support local OpenAI-compatible embeddings
by lumenradley · 2026-02-15
75.7%
#16634: feat(memory-lancedb): make auto-capture min length configurable
by ciberponk · 2026-02-14
75.7%
#14576: Fix/memory loss bugs
by ENCHIGO · 2026-02-12
74.7%
#8795: feat(memory): add Redis-backed long-term memory plugin
by tf-gmail · 2026-02-04
74.2%
#9026: fix(session-memory): sanitize content to prevent binary data in mem...
by Flamrru · 2026-02-04
74.1%
#11226: Fix system property assignment in cache-trace.ts
by ygypt · 2026-02-07
74.0%