Skip to content

fix: add missing text_lemmatized in AsyncMemory._create_memory#4886

Merged
kartik-mem0 merged 1 commit intomem0ai:mainfrom
ixchio:fix/async-create-memory-missing-text-lemmatized
Apr 23, 2026
Merged

fix: add missing text_lemmatized in AsyncMemory._create_memory#4886
kartik-mem0 merged 1 commit intomem0ai:mainfrom
ixchio:fix/async-create-memory-missing-text-lemmatized

Conversation

@ixchio
Copy link
Copy Markdown
Contributor

@ixchio ixchio commented Apr 18, 2026

Linked Issue

This is a newly discovered bug — no existing issue.

Description

AsyncMemory._create_memory was missing the text_lemmatized field computation, unlike its sync counterpart Memory._create_memory (line 1591). This caused all memories created via AsyncMemory with infer=False to be invisible to BM25 keyword search, silently degrading search recall for all async users.

Root Cause

When _create_memory was ported from sync to async, the lemmatize_for_bm25() call was accidentally omitted. The sync version stores:

new_metadata["text_lemmatized"] = lemmatize_for_bm25(data)

But the async version at line 2994 was missing this line entirely. The hybrid scoring pipeline (semantic + BM25 + entity boost) relies on text_lemmatized for keyword matching — without it, BM25 scores are always zero for affected memories.

Impact

  • All AsyncMemory users using infer=False are silently affected
  • Keyword search recall drops to zero for memories created via the async path
  • No error is raised — the bug is completely silent, making it hard to detect

Fix

One-line addition to AsyncMemory._create_memory to compute and store text_lemmatized, matching the sync implementation.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactor (no functional changes)
  • Documentation update

Breaking Changes

N/A

Test Coverage

  • I added/updated unit tests
  • I added/updated integration tests
  • I tested manually (describe below)
  • No tests needed (explain why)

Added two regression tests:

  • test_sync_create_memory_stores_text_lemmatized — parity check confirming sync version works
  • test_async_create_memory_stores_text_lemmatized — regression test that would fail without this fix

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have added tests that prove my fix/feature works
  • New and existing tests pass locally
  • I have updated documentation if needed

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.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 18, 2026

CLA assistant check
All committers have signed the CLA.

@ixchio
Copy link
Copy Markdown
Contributor Author

ixchio commented Apr 18, 2026

Hey @Dev-Khant @deshraj @kartik-mem0 — would appreciate a review on this fix when you get a chance!

TL;DR: AsyncMemory._create_memory was missing the text_lemmatized = lemmatize_for_bm25(data) line that exists in the sync Memory._create_memory. This silently breaks BM25 keyword search for all memories created via the async path with infer=False.

One-line fix + two regression tests. All 36 tests pass, lint clean.

@kartik-mem0 kartik-mem0 merged commit 5be2630 into mem0ai:main Apr 23, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants