Skip to content

Fix #1448: fix: 添加包含偏好信息的记忆后,使用搜索接口POST /product/search无法检索到任何记忆#1983

Open
Memtensor-AI wants to merge 1 commit into
dev-v2.0.22from
bugfix/autodev-1448
Open

Fix #1448: fix: 添加包含偏好信息的记忆后,使用搜索接口POST /product/search无法检索到任何记忆#1983
Memtensor-AI wants to merge 1 commit into
dev-v2.0.22from
bugfix/autodev-1448

Conversation

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

Description

Fixes #1448/product/search (fine mode) returning empty results for memories added through the fast pipeline. Root cause: tree_text_memory._graph_recall filtered Neo4j candidates by n.key IN parsed_goal.keys and tag overlap ≥ 2, but fast-mode add stores the raw chat-formatted text as key and only ["mode:fast"] as tags, while fine-mode search asks the LLM for high-level semantic keys/tags, so the strict candidate set comes back empty and the structured branch silently dropped the memory.

The fix extracts a lenient _node_matches_parsed_goal post-filter that accepts substring key matches and a single tag overlap, and adds _fallback_candidates_by_substring which uses the existing graph_store.get_all_memory_items API (bounded to 50 candidates per call) to substring-match parsed_goal.keys against stored key + memory text whenever the strict candidate set is empty. The fallback is scoped to WorkingMemory / LongTermMemory / UserMemory / OuterMemory so PreferenceMemory and other specialized scopes keep their dedicated retrievers. Wrapped in try/except so unexpected backends silently degrade to the previous behavior. No API, schema, or migration impact.

Tests: 4 new regression tests in tests/memories/textual/test_tree_retriever.py cover the reporter's exact scenario, substring post-filter, single-tag overlap, and graceful empty return. All 62 tests under tests/memories/textual/ pass after the fix; ruff check and ruff format both clean. The 6 unrelated failures under tests/mem_reader/ and tests/api/ are pre-existing on the dev-20260624-v2.0.22 baseline (verified by stashing the fix and re-running).

Related Issue (Required): Fixes #1448

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Automated tests are pending.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have created related documentation issue/PR in MemOS-Docs (if applicable)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.

Reviewer Checklist

`/product/search` (fine mode) cannot find memories added through the fast
pipeline because `tree_text_memory._graph_recall` filters Neo4j candidates by
`n.key IN parsed_goal.keys` and tag overlap >= 2. Fast-mode add stores the
raw chat-formatted text as `key` and `["mode:fast"]` as `tags`, while
fine-mode search asks the LLM for high-level semantic keys/tags, so the
strict candidate set comes back empty and the structured branch silently
drops the memory.

Extract a lenient `_node_matches_parsed_goal` post-filter that also accepts
substring matches and a single tag overlap, and add
`_fallback_candidates_by_substring` which uses
`graph_store.get_all_memory_items` (bounded to 50) to recover fast-mode
memories. Restricted to WorkingMemory / LongTermMemory / UserMemory /
OuterMemory so PreferenceMemory and other scopes keep their dedicated
retrievers.

Regression tests cover the reporter's exact scenario, substring post-filter,
single-tag overlap, and graceful empty return.
@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

✅ Automated Test Results: PASSED

No applicable test scope for the changed files — automated tests skipped. Changed paths do not map to any configured scope (env.yaml source_mapping). Manual review recommended.

Branch: bugfix/autodev-1448

@Memtensor-AI Memtensor-AI changed the base branch from dev-20260624-v2.0.22 to dev-v2.0.22 June 30, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated bug Something isn't working | 功能异常

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants