From 7e1672447b4499574bad68e16261db2dc86ca523 Mon Sep 17 00:00:00 2001 From: Greyson LaLonde Date: Sat, 11 Apr 2026 02:01:23 +0800 Subject: [PATCH] fix: deflake MemoryRecord embedding serialization test Substring checks like `'0.1' not in json_str` collided with timestamps such as `2026-04-10T13:00:50.140557` on CI. Round-trip through `model_validate_json` to verify structurally that the embedding field is absent from the serialized output. --- lib/crewai/tests/memory/test_unified_memory.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/crewai/tests/memory/test_unified_memory.py b/lib/crewai/tests/memory/test_unified_memory.py index 05bb977ac..be52e6db5 100644 --- a/lib/crewai/tests/memory/test_unified_memory.py +++ b/lib/crewai/tests/memory/test_unified_memory.py @@ -51,14 +51,13 @@ def test_memory_record_embedding_excluded_from_serialization() -> None: dumped = r.model_dump() assert "embedding" not in dumped assert dumped["content"] == "hello" - - # model_dump_json excludes embedding json_str = r.model_dump_json() - assert "0.1" not in json_str assert "embedding" not in json_str + rehydrated = MemoryRecord.model_validate_json(json_str) + assert rehydrated.embedding is None # repr excludes embedding - assert "0.1" not in repr(r) + assert "embedding=" not in repr(r) # Direct attribute access still works for storage layer assert r.embedding is not None