Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(langchain): accept mapping values in LangGraph store (#5980)
Zayn Jarvis8fe792dd1497
diff --git a/examples/langchain/src/langchain_openviking/store.py b/examples/langchain/src/langchain_openviking/store.pyindex 1c546faa9..34aa37d28 100644--- a/examples/langchain/src/langchain_openviking/store.py+++ b/examples/langchain/src/langchain_openviking/store.py@@ -7,6 +7,7 @@ from __future__ import annotationsimport asyncioimport jsonimport logging+from collections.abc import Mappingfrom datetime import datetime, timezonefrom typing import TYPE_CHECKING, Any, Iterablefrom urllib.parse import quote, unquote@@ -160,7 +161,7 @@ class OpenVikingStore(BaseStore):self,namespace: tuple[str, ...],key: str,- value: dict[str, Any],+ value: Mapping[str, Any],index: bool | list[str] | None = None,*,ttl: Any = None,@@ -173,7 +174,7 @@ class OpenVikingStore(BaseStore):namespace = tuple(namespace)now = datetime.now(timezone.utc)data_uri = self._data_uri(namespace, key)- record = self._write_record(data_uri, namespace, key, value, now)+ record = self._write_record(data_uri, namespace, key, dict(value), now)effective_index = self.index if index is None else indexindex_uri = self._index_uri(namespace, key)diff --git a/tests/unit/test_langchain_integration.py b/tests/unit/test_langchain_integration.pyindex 3d7bcf90c..c182032d9 100644--- a/tests/unit/test_langchain_integration.py+++ b/tests/unit/test_langchain_integration.py@@ -1,6 +1,7 @@from __future__ import annotationsimport json+from types import MappingProxyTypefrom typing import Anyimport pytest@@ -1226,6 +1227,24 @@ def test_langgraph_store_round_trip_and_semantic_search():assert store.list_namespaces(prefix=("users",)) == [("users", "ada")][email protected]("use_batch", [False, True])+def test_langgraph_store_accepts_mapping_values(use_batch):+ store = OpenVikingStore(client=InMemoryOpenVikingClient())+ original = {"color": "azure", "nested": {"rank": 3}}+ value = MappingProxyType(original)++ if use_batch:+ store.batch([PutOp(namespace=("users", "ada"), key="preferences", value=value)])+ else:+ store.put(("users", "ada"), "preferences", value)++ item = store.get(("users", "ada"), "preferences")+ assert item.value == original+ assert isinstance(item.value, dict)+ assert store.search(("users",), query="azure")[0].value == original+ assert original == {"color": "azure", "nested": {"rank": 3}}++def test_langgraph_store_semantic_search_keeps_peer_id_out_of_retrieval():client = InMemoryOpenVikingClient()store = OpenVikingStore(client=client, actor_peer_id="peer-store")