Fix #1347: 建议:增加自动召回的短查询过滤参数(min_query_length)#1976
Open
Memtensor-AI wants to merge 1 commit into
Open
Conversation
Auto-recall previously fired on every prompt down to 2 characters, injecting unrelated history when users typed one-word confirmations like "好的", "可以", "运行", "继续", "?", "👍". Reporter (#1347) documented the noise injection, token waste, and behavioural drift this caused, and could only disable the symptom by switching off the whole auto-recall path via `allowPromptInjection=false`. Add a configurable threshold (`recall.autoRecallMinQueryLength`, default 4) that the `before_prompt_build` hook checks against the normalised query length before searching. Default of 4 filters every reporter-listed example phrase while keeping legitimate short queries ("fix bug" / "what is X") usable. Users wanting the more aggressive suggestion (10) can opt in; setting 0 restores pre-feature behaviour. Refs: #1347 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
✅ Automated Test Results: PASSEDAutomated tests inconclusive (auto-generated test defect); treated as non-blocking. Manual review recommended. Details: The contract tests target Branch: |
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.
Description
Adds a new
recall.autoRecallMinQueryLengthconfig knob (default 4) to@memtensor/memos-local-openclaw-pluginso that very short user prompts no longer trigger thebefore_prompt_buildauto-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 < 2skip inapps/memos-local-openclaw/index.tswith 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 suggested10can opt in via config, and setting0restores the pre-feature behaviour. The knob only affects automatic recall — explicitmemory_searchtool calls are unchanged.Changes:
src/types.tsadds the field toMemosLocalConfig.recalland a default inDEFAULTS;src/config.tsresolves it inresolveConfig;index.tsuses it in the auto-recall hook;README.mddocuments it. Three new vitest cases intests/config.test.tscover default / override / explicit-zero. All 5 new config tests pass; the 19 tests acrossconfig,plugin-openclaw-wiring,plugin-impl-access, andrecallmodules all pass.tsc --noEmitis 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.Related Issue (Required): Fixes #1347
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.
Reviewer Checklist