Fix memory search fallback when embeddings are unavailable#1052
Fix memory search fallback when embeddings are unavailable#1052wayyoungboy wants to merge 1 commit into
Conversation
wayyoungboy
left a comment
There was a problem hiding this comment.
Review result: not ready to merge yet.
Findings:
- Blocker: the branch no longer merges cleanly with the current main branch. The conflicts are in
src/powermem/storage/adapter.pyandsrc/server/models/request.py, so this needs a rebase or merge conflict resolution before final review. - Compatibility risk: the new top-level filter key handling in
StorageAdapterchanges plain filter semantics for user metadata keys that collide with promoted payload fields such ashash,data,created_at,updated_at, andfulltext_content. Existing callers using plain filters for metadata keys with those names can miss unless they use an explicitmetadata.*filter. Please either preserve the previous metadata-filter behavior or document and test the intended syntax.
Validation:
- Targeted unit/integration tests passed in a local Python 3.11 environment:
python -m pytest tests/unit/test_sqlite_fts.py tests/unit/test_memory.py tests/unit/server/test_search_score_threshold.py tests/unit/test_list_memory_filters.py tests/integration/test_sqlite_fts_integration.py - E2E check passed through the public
MemoryAPI using SQLite storage: added two memories, forced search embedding generation to fail, and verified FTS fallback returned only the matching user-scoped result.
No LGTM because this PR is authored from the wayyoungboy fork and still has merge conflicts.
fb7c41f to
2b5f257
Compare
|
Updated this PR after review:
Validation:
|
2b5f257 to
5f7d879
Compare
|
Updated this PR after review:
Validation:
|
|
Added the remaining OceanBase E2E validation for this PR:
Latest PR checks are green; release-only jobs that are not expected for this PR are skipped by workflow rules. |
|
Self-review status for the current head: the branch is mergeable and current checks are green. The latest version keeps explicit no-embedding mode backward compatible: default search remains empty when embeddings are intentionally disabled, while transient embedding failures can still fall back to FTS on supported stores; explicit I do not see a new blocker in this static review. This should stay aligned with #1091 before either path lands, because #1091 currently changes the default no-embedding search behavior in the opposite direction. I am not marking this LGTM because this PR is authored from the |
|
@wayyoungboy — The FTS path assigns SQLite ( payload['_fts_score'] = float(fts_score)
payload['_quality_score'] = 1.0 # hardcodedOceanBase ( metadata['_fts_score'] = fts_score
metadata['_quality_score'] = fts_score # raw BM25 score (magnitude ~1e-6)
# core/memory.py
quality_score = result.get("_quality_score")
if quality_score is None:
quality_score = metadata.get("_quality_score")
if quality_score is not None and quality_score < threshold:
continueWith
Same code, same Note: Side note: please also confirm For coordination: PR #1091 will be revised to drop its automatic FTS-fallback contract (which conflicted with this PR's "explicit no-embedding mode stays empty by default" stance) and will wait for #1052 to land before adding complementary MCP-layer |
Summary
mainand preserve metadata filters whose names collide with payload fields such ashashanddataTests
python -m pytest --ignore=tests/regression -m "not e2e and not e2e_config"python -m pytest tests/unit/test_sqlite_fts.py tests/unit/test_memory.py tests/unit/server/test_search_score_threshold.py tests/unit/test_list_memory_filters.py tests/integration/test_sqlite_fts_integration.pypython -m pytest tests/unit/test_intelligence_forget_soft_mark.py tests/integration/test_noop_embedding_mode.py tests/unit/test_noop_embedding.py -qMemoryAPI E2E with SQLite in-memory: forced embedding generation failure, then verified FTS fallback returns the single result matching collision-prone metadata filters; also verified explicitly disabled embeddings keep default search emptyMemoryAPI E2E with a remote OceanBase test database: forced embedding generation failure, then verified OceanBase FTS fallback returns the expected metadata-filtered result; also verified explicitly disabled embeddings keep default search empty while explicit FTS retrieval still worksFixes #1046