feat: add exposeRetrievalMetadata and clean recall output#113
feat: add exposeRetrievalMetadata and clean recall output#113Disaster-Terminator wants to merge 3 commits intoCortexReach:mainfrom
Conversation
- Rename sanitizeMemoryForSerialization to buildSanitizedMemoryPayload - Preserve details.candidates for forget/update tools instead of replacing with memories - Add explicit types for SerializedMemory, DebugMemory, SerializedMemoryPayload - Extend test coverage to verify candidates contract and clean text output
rwmjhb
left a comment
There was a problem hiding this comment.
Thanks for the clean resubmission from #107.
Two things to address before merging:
1. Branch needs rebase — vllm-provider test will be dropped
Your branch is based on a commit before PR #76 landed. The current main has test/vllm-provider.test.mjs in the test script, but your package.json change overwrites that line without it:
# current main
"test": "node test/vllm-provider.test.mjs && node test/embedder-error-hints.test.mjs && ..."
# this PR
"test": "node test/embedder-error-hints.test.mjs && ... && node --test test/memory-recall-metadata.test.mjs ..."Please rebase onto latest main and include vllm-provider.test.mjs in the test script.
2. details payload shape change is a silent breaking change
Removing score and sources from details.memories[*] / details.candidates[*] by default changes the response schema. Any downstream consumer reading result.details.memories[0].score will get undefined after this change.
I understand the motivation (reducing token noise in LLM context), but this should be treated as an explicit breaking change rather than an internal cleanup. Suggestions:
- Option A: Keep
score/sourcesindetails.memories(structured data is not LLM-visible token cost), only clean thecontent[].textstring. This avoids any schema breakage. - Option B: If removing from
detailsis intentional, document it as a breaking change and bump accordingly.
The content[].text cleanup (removing 82%, vector+BM25+reranked from the human-readable string) is unambiguously good and non-breaking. The details object change is where the concern lies.
|
I'll analyze this and get back to you. |

Background
autoRecallinjection andmemory_recallcurrently include retrieval metadata in their default output, for example:[category:scope] text (80%, vector+BM25+reranked)That information can be useful while debugging retrieval behavior, but it is noisy in normal operation:
This PR is a follow-up to #107. PR #107 was closed because unrelated upstream commits were accidentally mixed in during squash. This revision reapplies only the intended retrieval-metadata change on top of the current
main.What this PR changes
1. Hide retrieval metadata by default
(score, sources)suffixes fromautoRecallinjected lines;memory_recall;scoreandsourcesindetails.memoriesby default.2. Add an explicit debug switch
Introduce a new
exposeRetrievalMetadataconfig option, defaulting tofalse.When enabled, retrieval metadata is exposed separately via
details.debug, instead of being mixed into the default text output.3. Preserve existing candidate response structure
For the candidate flows in
memory_forgetandmemory_update, keep the existingdetails.candidatesstructure and attachdetails.debugonly when needed. This avoids introducing an unnecessary response-shape change.Files changed
index.tsexposeRetrievalMetadatainto tool contextsrc/tools.tsopenclaw.plugin.jsonexposeRetrievalMetadataconfig optiontest/memory-recall-metadata.test.mjspackage.jsonValidation
npm ci npm testResult: 41/41 passing.
Scope
This revision is intentionally limited to: