The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
fix: preserve empty Azure AI Search update values (#5524)
Xiaoju43175d85f234
diff --git a/mem0/vector_stores/azure_ai_search.py b/mem0/vector_stores/azure_ai_search.pyindex 76235fd0c..60b49bdf2 100644--- a/mem0/vector_stores/azure_ai_search.py+++ b/mem0/vector_stores/azure_ai_search.py@@ -298,9 +298,9 @@ class AzureAISearch(VectorStoreBase):payload (Dict, optional): Updated payload."""document = {"id": vector_id}- if vector:+ if vector is not None:document["vector"] = vector- if payload:+ if payload is not None:json_payload = json.dumps(payload)document["payload"] = json_payloadfor field in ["user_id", "run_id", "agent_id"]:diff --git a/tests/vector_stores/test_azure_ai_search.py b/tests/vector_stores/test_azure_ai_search.pyindex 1478d90c4..b05393898 100644--- a/tests/vector_stores/test_azure_ai_search.py+++ b/tests/vector_stores/test_azure_ai_search.py@@ -511,6 +511,30 @@ def test_insert_with_http_error(azure_ai_search_instance):assert "Azure service error" in str(exc_info.value)+def test_update_allows_empty_payload(azure_ai_search_instance):+ """Test updating with an empty payload explicitly clears stored payload data."""+ instance, mock_search_client, _ = azure_ai_search_instance++ mock_search_client.merge_or_upload_documents.return_value = [{"status": True, "id": "doc1", "status_code": 200}]++ instance.update("doc1", payload={})++ mock_search_client.merge_or_upload_documents.assert_called_once_with(+ documents=[{"id": "doc1", "payload": "{}", "user_id": None, "run_id": None, "agent_id": None}]+ )+++def test_update_allows_empty_vector(azure_ai_search_instance):+ """Test updating with an empty vector still sends the vector field to Azure."""+ instance, mock_search_client, _ = azure_ai_search_instance++ mock_search_client.merge_or_upload_documents.return_value = [{"status": True, "id": "doc1", "status_code": 200}]++ instance.update("doc1", vector=[])++ mock_search_client.merge_or_upload_documents.assert_called_once_with(documents=[{"id": "doc1", "vector": []}])++# --- Tests for search method ---