fix(tests): update 35 failing tests for v3 single-pass pipeline
Tests were written for the old two-pass extraction pipeline (extract
facts + merge with ADD/UPDATE/DELETE). V3 uses single-pass ADD-only
extraction with one LLM call returning {"memory": [...]}.
Changes by category:
Old pipeline tests (13 failures):
- Delete TestHallucinatedIdGuard entirely (tests UPDATE/DELETE ID
resolution that no longer exists)
- Update error log assertions to match v3 log messages
- Change LLM mock from 2-call side_effect to 1-call return_value
- Update vllm thinking tag tests for single-call format
ensure_json_instruction removed (3):
- Delete source-inspection tests (function still exists in utils
but is no longer called from _add_to_vector_store)
UTC timestamp normalization removed (2):
- Update expected timestamps to stored-as-is (no UTC conversion)
- Remove _normalize_iso_timestamp_to_utc import
_search_vector_store signature: top_k -> limit (2):
- Update test calls to use limit= parameter
Context manager + close/db removed (6):
- Delete tests for __enter__/__exit__/close/db that were removed
Vector store BM25 config (3):
- Qdrant: add sparse_vectors_config to create_col assertion,
named vector format {"": vector} in update assertion
- MongoDB: assert_any_call for both vector + text search indexes
Misc (6):
- test_search_handles_incomplete_payloads: expect 1 result (v3
filters entries without 'data' key)
- Embedding cache tests: update for embed_batch (1 call) vs
individual embed (was 2 calls)
- Graph reset tests: delete (graph support removed)
- use_azure_credential: update expected sensitivity to True
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
2a5ffd0976
commit
0b4bbcefff
+16
-18
@@ -187,22 +187,21 @@ def create_mocked_async_memory():
|
||||
def test_thinking_tags_sync():
|
||||
"""Test thinking tags handling in Memory._add_to_vector_store (sync)."""
|
||||
memory, mock_llm, mock_vector_store = create_mocked_memory()
|
||||
|
||||
# Mock LLM responses for both phases
|
||||
|
||||
# v3 pipeline: single LLM call returning ADD-only memories
|
||||
mock_llm.generate_response.side_effect = [
|
||||
' <think>Sync fact extraction</think> \n{"facts": ["User loves sci-fi"]}',
|
||||
' <think>Sync memory actions</think> \n{"memory": [{"text": "Loves sci-fi", "event": "ADD"}]}'
|
||||
'<think>Sync extraction</think>\n{"memory": [{"text": "Loves sci-fi", "attributed_to": "user"}]}'
|
||||
]
|
||||
|
||||
|
||||
mock_vector_store.search.return_value = []
|
||||
|
||||
|
||||
result = memory._add_to_vector_store(
|
||||
messages=[{"role": "user", "content": "I love sci-fi movies"}],
|
||||
metadata={},
|
||||
filters={},
|
||||
metadata={},
|
||||
filters={},
|
||||
infer=True
|
||||
)
|
||||
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0]["memory"] == "Loves sci-fi"
|
||||
assert result[0]["event"] == "ADD"
|
||||
@@ -213,13 +212,12 @@ def test_thinking_tags_sync():
|
||||
async def test_async_thinking_tags_async():
|
||||
"""Test thinking tags handling in AsyncMemory._add_to_vector_store."""
|
||||
memory, mock_llm, mock_vector_store = create_mocked_async_memory()
|
||||
|
||||
# Directly mock llm.generate_response instead of via asyncio.to_thread
|
||||
|
||||
# v3 pipeline: single LLM call returning ADD-only memories
|
||||
mock_llm.generate_response.side_effect = [
|
||||
' <think>Async fact extraction</think> \n{"facts": ["User loves sci-fi"]}',
|
||||
' <think>Async memory actions</think> \n{"memory": [{"text": "Loves sci-fi", "event": "ADD"}]}'
|
||||
'<think>Async extraction</think>\n{"memory": [{"text": "Loves sci-fi", "attributed_to": "user"}]}'
|
||||
]
|
||||
|
||||
|
||||
# Mock asyncio.to_thread to call the function directly (bypass threading)
|
||||
async def mock_to_thread(func, *args, **kwargs):
|
||||
if func == mock_llm.generate_response:
|
||||
@@ -230,15 +228,15 @@ async def test_async_thinking_tags_async():
|
||||
return []
|
||||
else:
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
||||
with patch('mem0.memory.main.asyncio.to_thread', side_effect=mock_to_thread):
|
||||
result = await memory._add_to_vector_store(
|
||||
messages=[{"role": "user", "content": "I love sci-fi movies"}],
|
||||
metadata={},
|
||||
effective_filters={},
|
||||
metadata={},
|
||||
effective_filters={},
|
||||
infer=True
|
||||
)
|
||||
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0]["memory"] == "Loves sci-fi"
|
||||
assert result[0]["event"] == "ADD"
|
||||
Reference in New Issue
Block a user