建议:增加自动召回的短查询过滤参数(min_query_length)
问题描述
在使用 memos-local-openclaw-plugin 过程中,发现自动召回机制存在明显的"短词召回污染"问题:
问题场景
用户日常对话中经常出现以下短词:
- 好的 / 可以 / 没错 / 运行 / 执行 / 继续 / ? / 赞
这些词本质上是语气词或确认词,几乎没有实际语义。但自动召回会把它们当作查询词,从记忆库中搜索相关内容并注入上下文。
造成的问题
- 噪音注入:召回到的往往是向量相似度高但语义关联度低的历史记忆,对当前对话毫无帮助
- Token 浪费:每次短词触发都会注入 700-1500 chars 的无用内容,加速 context 窗口消耗
- 行为歧义:例如用户只说"好的"确认一件事,却被植入一堆不相关的历史记录,容易让 Agent 误解用户意图
- 潜在风险:记忆污染可能导致 Agent 基于不相关的历史做出错误判断和操作
实际案例
用户消息:"先这样"(结束对话的确认)
自动召回结果:
- 召回到用户之前吐槽 MiniMax 的内容(与"先这样"无关)
- 召回到不相关的 test 任务记录
这些内容对回答"先这样"没有任何正向作用,反而增加了理解成本。
建议方案
参考业界通用做法,添加一个短查询过滤参数:
memory_search:
min_query_length: 10 # 少于10字的查询不触发召回
或作为召回配置项:
{
"recall": {
"minQueryLength": 10
}
}
替代方案(如果上述实现复杂)
提供 auto_recall_min_query_length 插件级别配置,阻止短查询触发自动召回。
当前临时解决方案
目前通过设置 plugins.entries.memos-local-openclaw-plugin.hooks.allowPromptInjection = false 来禁用自动召回,但这也同时禁用了所有召回功能,用户体验不佳。
使用环境
- memos-local-openclaw-plugin: v1.0.6-beta.11
- OpenClaw: 2026.3.x
- 记忆库规模:约 7000 条记录
期待官方考虑加入这个功能!中文技术支持响应也很及时 👍
This issue has been automatically marked as stale due to inactivity.
💬 我也在做记忆系统相关的工作:CausaMem,可以来看看,说不定有能借鉴的地方 🙂
🤖 AutoDev has picked up this issue and started working on it.
Task ID: 42bc646552bc9665
Working branch: feature/autodev-1347
Target branch: latest dev* branch
Workflow: opsp (analysis → coding → testing → PR)
I will post the PR link here once done. If I need more information, I will ask in the comments.
✅ AutoDev task 42bc646552bc9665 completed.
Summary: Adds a new recall.autoRecallMinQueryLength config knob (default 4) to @memtensor/memos-local-openclaw-plugin so that very short user prompts no longer trigger the before_prompt_build auto-recall pipeline. This addresses the "short-word recall pollution" issue (#1347) where one-word confirmations like "好的"/"可以"/"运行"/"继续"/"?" would fire vector + FTS search and inject 700-1500 chars of unrelated history into the agent context.
The fix replaces the previous hard-coded query.length < 2 skip in apps/memos-local-openclaw/index.ts with a comparison against the configured threshold. The default of 4 chars filters every reporter-listed example while keeping legitimate short queries usable; users wanting the reporter's suggested 10 can opt in via config, and setting 0 restores the pre-feature behaviour. The knob only affects automatic recall — explicit memory_search tool calls are unchanged.
Changes: src/types.ts adds the field to MemosLocalConfig.recall and a default in DEFAULTS; src/config.ts resolves it in resolveConfig; index.ts uses it in the auto-recall hook; README.md documents it. Three new vitest cases in tests/config.test.ts cover default / override / explicit-zero. All 5 new config tests pass; the 19 tests across config, plugin-openclaw-wiring, plugin-impl-access, and recall modules all pass. tsc --noEmit is clean. The 4 unrelated failing files in the full sweep (skill-auto-install, task-processor, update-install) were verified to fail identically on the base branch before any edits in this PR.
Base branch: main
Branch: feature/autodev-1347
Commit: 21dedb3
PR: https://github.com/MemTensor/MemOS/pull/1976
Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller
Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller