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(fs): 修复写入文件参数不匹配错误 (#1687)
Spike335bfbb97f6b
diff --git a/openviking/storage/content_write.py b/openviking/storage/content_write.pyindex c88197227..db2ab3ed4 100644--- a/openviking/storage/content_write.py+++ b/openviking/storage/content_write.py@@ -296,7 +296,9 @@ class ContentWriteCoordinator:existing_raw = await self._viking_fs.read_file(uri, ctx=ctx)_, metadata = deserialize_full(existing_raw)if metadata:- content = serialize_with_metadata(content, metadata)+ metadata_with_content = metadata.copy()+ metadata_with_content["content"] = content+ content = serialize_with_metadata(metadata_with_content)await self._viking_fs.write_file(uri, content, ctx=ctx)return@@ -305,7 +307,9 @@ class ContentWriteCoordinator:existing_content, metadata = deserialize_full(existing_raw)updated_content = existing_content + contentif metadata:- updated_raw = serialize_with_metadata(updated_content, metadata)+ metadata_with_content = metadata.copy()+ metadata_with_content["content"] = updated_content+ updated_raw = serialize_with_metadata(metadata_with_content)else:updated_raw = updated_contentawait self._viking_fs.write_file(uri, updated_raw, ctx=ctx)diff --git a/tests/server/test_content_write_service.py b/tests/server/test_content_write_service.pyindex 0b42031f5..ff340459e 100644--- a/tests/server/test_content_write_service.py+++ b/tests/server/test_content_write_service.py@@ -70,7 +70,7 @@ async def test_memory_replace_preserves_metadata(service):"updated_at": "2026-04-01T10:05:00","fields": {"topic": "theme"},}- full_content = serialize_with_metadata("Original preference", metadata)+ full_content = serialize_with_metadata({**metadata, "content": "Original preference"})_, expected_metadata = deserialize_full(full_content)await service.viking_fs.write_file(memory_uri, full_content, ctx=ctx)@@ -88,6 +88,34 @@ async def test_memory_replace_preserves_metadata(service):assert stored_metadata == expected_metadata+async def test_memory_append_preserves_metadata(service):+ ctx = RequestContext(user=service.user, role=Role.USER)+ memory_uri = f"viking://user/{ctx.user.user_space_name()}/memories/preferences/theme.md"+ metadata = {+ "tags": ["ui", "preference"],+ "created_at": "2026-04-01T10:00:00",+ "updated_at": "2026-04-01T10:05:00",+ "fields": {"topic": "theme"},+ }+ full_content = serialize_with_metadata({**metadata, "content": "Original preference"})+ _, expected_metadata = deserialize_full(full_content)+ await service.viking_fs.write_file(memory_uri, full_content, ctx=ctx)++ await service.fs.write(+ memory_uri,+ content="\nUpdated preference",+ ctx=ctx,+ mode="append",+ )++ stored = await service.viking_fs.read_file(memory_uri, ctx=ctx)+ stored_content, stored_metadata = deserialize_full(stored)++ assert stored_content == "Original preference\nUpdated preference"+ assert stored_metadata == expected_metadata++@pytest.mark.asyncioasync def test_memory_write_vector_refresh_includes_generated_summary(monkeypatch):file_uri = "viking://user/default/memories/preferences/theme.md"