fix(memory): normalize OpenClaw content blocks + BM25 OR fallback + audit_log sanitization#1407
Open
zhangtaibo wants to merge 1 commit into
Open
Conversation
…udit_log sanitization
|
云孟 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: agent-memory auto-capture trigger + BM25 OR fallback + audit_log sanitization
Fixes #1405
Problem
Three issues in agent-memory:
OpenClaw adapter auto-capture (
openclaw/src/index.ts):agent_endhook usedlastAsst.contentdirectly as a string, but OpenClaw sends content as an array of content blocks[{type:"text", text:"..."}]. This causedre.test(lastAsst.content)to coerce the array to"[object Object]", so no trigger regex ever matched and auto-capture never fired.BM25 FTS5 AND-only query (
src/index/store.rs): When any single query term is absent from the corpus, the implicit-AND FTS5 MATCH returns 0 results. Natural-language prompts routinely contain common words not in any memory file, causing every AND query to fail silently.audit_log query leakage (
src/tools/memory_search.rs):format!("{:.120}", query)wrote the first 120 chars of user queries into the audit log path field, potentially leaking sensitive information.Fix
lastAsst.contentfrom content-block array to string before trigger matching and hashing.'"token1" OR "token2" OR ...'so partial matches still surface.format!("{:.120}", query)withformat!("bm25:len={}", query.len())across all audit_log calls.Verification
git apply patch+bash scripts/rpm-build.sh agent-memory→ exit 0agent-memory-0.2.1-1.alnx4.x86_64.rpm(5.0M)test_auto_capture_persists_trigger_phrase,test_auto_recall_injects_without_tool_call,test_memory_get_reads_seeded_file(to be verified on ECS with installed RPM)Test Cases
tests/test_openclaw_e2e.py::TestAutoCapture::test_auto_capture_persists_trigger_phrasetests/test_openclaw_e2e.py::TestAutoRecall::test_auto_recall_injects_without_tool_calltests/test_openclaw_e2e.py::TestMemoryGet::test_memory_get_reads_seeded_file