fix: add missing text_lemmatized in AsyncMemory._create_memory#4886
Merged
kartik-mem0 merged 1 commit intomem0ai:mainfrom Apr 23, 2026
Merged
Conversation
AsyncMemory._create_memory was not setting the 'text_lemmatized' field in the vector store payload, unlike its sync counterpart Memory._create_memory. This caused all memories created via AsyncMemory with infer=False to be invisible to BM25 keyword search, silently degrading search recall for async users. The hybrid scoring pipeline (semantic + BM25 + entity boost) would never find keyword matches for these memories since the lemmatized text field was empty/missing. Root cause: when _create_memory was ported from sync to async, the lemmatize_for_bm25() call was accidentally omitted. Fix: add the missing text_lemmatized computation, matching the sync version. Tests: add regression tests for both sync and async _create_memory to verify text_lemmatized is stored in the vector store payload.
Contributor
Author
|
Hey @Dev-Khant @deshraj @kartik-mem0 — would appreciate a review on this fix when you get a chance! TL;DR: One-line fix + two regression tests. All 36 tests pass, lint clean. |
kartik-mem0
approved these changes
Apr 23, 2026
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.
Linked Issue
This is a newly discovered bug — no existing issue.
Description
AsyncMemory._create_memorywas missing thetext_lemmatizedfield computation, unlike its sync counterpartMemory._create_memory(line 1591). This caused all memories created viaAsyncMemorywithinfer=Falseto be invisible to BM25 keyword search, silently degrading search recall for all async users.Root Cause
When
_create_memorywas ported from sync to async, thelemmatize_for_bm25()call was accidentally omitted. The sync version stores:But the async version at line 2994 was missing this line entirely. The hybrid scoring pipeline (
semantic + BM25 + entity boost) relies ontext_lemmatizedfor keyword matching — without it, BM25 scores are always zero for affected memories.Impact
AsyncMemoryusers usinginfer=Falseare silently affectedFix
One-line addition to
AsyncMemory._create_memoryto compute and storetext_lemmatized, matching the sync implementation.Type of Change
Breaking Changes
N/A
Test Coverage
Added two regression tests:
test_sync_create_memory_stores_text_lemmatized— parity check confirming sync version workstest_async_create_memory_stores_text_lemmatized— regression test that would fail without this fixChecklist