Enhance memos-local retrieval with modular logic and LLM integration#1226
Open
lcpdeb wants to merge 3 commits intoMemTensor:mainfrom
Open
Enhance memos-local retrieval with modular logic and LLM integration#1226lcpdeb wants to merge 3 commits intoMemTensor:mainfrom
lcpdeb wants to merge 3 commits intoMemTensor:mainfrom
Conversation
…he memos-local memory retrieval system. Key Improvements: - Modularized Intent Logic: Extracted judgment logic into dedicated `intent-filter.ts` and `intent-patterns.ts` to allow for specialized local processing. - Persistent Intent Filtering: Implemented a reliable filter mechanism that survives restarts, ensuring consistent recall behavior. - Advanced Regex Pattern Matching: Replaced brittle regex literals with dynamic `new RegExp()` constructors to fix UTF-8 encoding issues and support multi-language scenarios. - LLM-Powered Judgment: Integrated an LLM-based intent analyzer with configurable timeouts and fallbacks to reduce irrelevant memory searches. - Performance Optimization: Added query normalization (trimming) and filter-out logic for conversational fillers/real-time queries. - Configuration Integration: Exposed `llmTimeoutMs` and `autoRecallMaxResults` settings to the plugin configuration interface. - Quality Assurance: Introduced a full Vitest suite in `tests/intent-filter.test.ts` to validate intent branching and edge cases. These changes collectively reduce context pollution and improve the overall "intelligence" of the auto-recall feature.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an intent-filtering layer to the memos-local-openclaw plugin’s auto-recall flow, aiming to reduce irrelevant memory retrieval by using pattern rules first and an LLM-based judge when needed.
Changes:
- Added
intent-patterns.ts(regex pattern sources + compile/match utilities) andintent-filter.ts(skip/search/LLM-judge decision flow + output parsing + max-results resolver). - Integrated intent-judging into
before_agent_startauto-recall inindex.ts, including configurableautoRecallMaxResults. - Added Vitest coverage for skip/search rules, LLM output parsing, timeouts, and fallback behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| apps/memos-local-openclaw/index.ts | Wires the new intent filter into auto-recall and reads plugin config for intent-filter options. |
| apps/memos-local-openclaw/src/intent-filter.ts | Implements intent decision logic (patterns + optional LLM judge), parsing, and max-results resolution. |
| apps/memos-local-openclaw/src/intent-patterns.ts | Defines and compiles regex pattern sources for skip and explicit memory queries. |
| apps/memos-local-openclaw/tests/intent-filter.test.ts | Adds unit tests validating the intent-filter branching and parsing behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+161
to
162
| const intentFilterOptions = ((pluginCfg as any).intentFilter ?? {}) as any; | ||
| const stateDir = api.resolvePath("~/.openclaw"); |
Comment on lines
+262
to
+266
| const intentResult = await Promise.race([ | ||
| summarizer.summarize(intentCheck.llmPrompt!), | ||
| timeoutPromise, | ||
| ]).finally(() => { | ||
| if (tid !== undefined) timerApi.clearTimeout(tid); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
… and auto-recall settings
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.
This pull request introduces a new intent filter module to improve the precision of memory retrieval in the
memos-local-openclawapp. The changes add configurable logic to determine whether a user query should trigger memory search, skip retrieval, or require LLM-based intent judgment. The module is rigorously tested and integrated into the auto-recall flow, allowing for more relevant memory hits and reducing context pollution from irrelevant queries.Intent filter module and pattern matching:
intent-filter.tsmodule implementing intent judgment logic, including pattern-based skip/search rules, LLM prompt generation, output parsing, and configuration options.intent-patterns.tscontaining regex patterns for skip and explicit memory recall, along with utilities for compiling and matching patterns.Integration and configuration:
index.ts, usingexecuteIntentJudgeto decide whether to proceed with memory search and applying configurable max results. [1] [2] [3]Testing and validation:
intent-filter.test.tscovering skip/search rules, LLM output parsing, fallback behaviors, and configuration value clamping.Key Improvements:intent-filter.tsandintent-patterns.tsto allow for specialized local processing.new RegExp()constructors to fix UTF-8 encoding issues and support multi-language scenarios.llmTimeoutMsandautoRecallMaxResultssettings to the plugin configuration interface.tests/intent-filter.test.tsto validate intent branching and edge cases.These changes collectively reduce context pollution and improve the overall "intelligence" of the auto-recall feature.
Description
Please include a summary of the change, the problem it solves, the implementation approach, and relevant context. List any dependencies required for this change.
Related Issue (Required): Fixes @issue_number
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist
Reviewer Checklist