fix(openclaw-plugin): store memories via content/write API instead of session messages#2169
fix(openclaw-plugin): store memories via content/write API instead of session messages#2169chdlc wants to merge 1 commit into
Conversation
… session messages _tool_remember (memory_store) was posting memories as session messages that depend on commit-time VLM extraction to persist. With extraction_enabled: false (no VLM configured), the extraction pipeline never processes these messages — memories are silently lost. Replace with direct POST to /api/v1/content/write?mode=create, which creates the file, stores the content, and queues vector indexing in a single API call. Error reporting is immediate — no silent failures. - Maps memory_store category to viking:// subdirectory - Generates UUID-based URIs via randomUUID().replace(/-/g, '').slice(0, 12) - Returns byte count in confirmation message - Updates tests to verify content/write call, category mapping, and error handling
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
|
Thanks for the fix. I agree it addresses the immediate failure case, but I don’t think we should merge it as-is. Directly writing raw text via content/write bypasses the memory v2 schema pipeline, including structured fields, expected paths, merge behavior, and MEMORY_FIELDS metadata. This may make manually stored memories inconsistent with commit-generated memories. For now, I suggest returning a clear tool error when the LLM/extraction pipeline is unavailable, instead of bypassing the normal memory pipeline. |
Description
The
memory_storecommand (_tool_remember) was posting memory text as session messages that depend on commit-time VLM extraction to persist. Whenextraction_enabled: false(no VLM configured), the extraction pipeline never processes these messages, and memories are silently lost.Replace with a direct POST to
/api/v1/content/write?mode=create, which creates the file, stores the content, and queues vector indexing in a single API call — no VLM extraction dependency, immediate write confirmation, and immediate error reporting.Related Issue
Addresses the same pattern identified in hermes-agent PR #29733 — session-commit-based memory storage silently fails when extraction is disabled.
Type of Change
Changes Made
examples/openclaw-plugin/client.ts: AddedcontentWrite(uri, content, mode, agentId)method — POST to/api/v1/content/writeexamples/openclaw-plugin/index.ts: Rewrotememory_storetool:addSessionMessage+commitSession)contentWritedirectly with URIviking://user/{userId}/memories/{subdir}/mem_{uuid}.mdcategoryparameter (preference,entity,event,case,pattern) mapped to subdirectoriesexamples/openclaw-plugin/tests/ut/tools.test.ts: Updatedmemory_storetests:content/writecall with correct URI shapeevent→events/)Testing
Test results: 24/24 test files, 468 tests passed.
TypeScript compiles cleanly with
tsc --noEmit.Checklist
Additional Notes
The same
content/writeendpoint is already used by other parts of the OpenViking ecosystem for durable writes. This change makesmemory_storeconsistent with that pattern, removing the runtime dependency on VLM extraction for memory persistence. When VLM extraction is enabled, the pipeline still processes the new file asynchronously as normal.