From d6cfeae913f26280ac936dce66c5a44552b97476 Mon Sep 17 00:00:00 2001 From: Sarah Wooders Date: Mon, 24 Mar 2025 21:57:52 -0700 Subject: [PATCH] feat: remove `identities` from .af (#1388) --- letta/serialize_schemas/marshmallow_agent.py | 3 +++ letta/serialize_schemas/marshmallow_block.py | 2 +- letta/serialize_schemas/marshmallow_tool.py | 2 +- letta/serialize_schemas/pydantic_agent_schema.py | 7 ------- tests/test_agent_serialization.py | 5 +++++ 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/letta/serialize_schemas/marshmallow_agent.py b/letta/serialize_schemas/marshmallow_agent.py index 182fb559..12ce873d 100644 --- a/letta/serialize_schemas/marshmallow_agent.py +++ b/letta/serialize_schemas/marshmallow_agent.py @@ -105,4 +105,7 @@ class MarshmallowAgentSchema(BaseSchema): "sources", "source_passages", "agent_passages", + "identities", + "is_deleted", + "groups", ) diff --git a/letta/serialize_schemas/marshmallow_block.py b/letta/serialize_schemas/marshmallow_block.py index 6432f642..6325f2c8 100644 --- a/letta/serialize_schemas/marshmallow_block.py +++ b/letta/serialize_schemas/marshmallow_block.py @@ -12,4 +12,4 @@ class SerializedBlockSchema(BaseSchema): class Meta(BaseSchema.Meta): model = Block - exclude = BaseSchema.Meta.exclude + ("agents",) + exclude = BaseSchema.Meta.exclude + ("agents", "identities", "is_deleted") diff --git a/letta/serialize_schemas/marshmallow_tool.py b/letta/serialize_schemas/marshmallow_tool.py index 3ae65ceb..44f64a97 100644 --- a/letta/serialize_schemas/marshmallow_tool.py +++ b/letta/serialize_schemas/marshmallow_tool.py @@ -12,4 +12,4 @@ class SerializedToolSchema(BaseSchema): class Meta(BaseSchema.Meta): model = Tool - exclude = BaseSchema.Meta.exclude + exclude = BaseSchema.Meta.exclude + ("is_deleted",) diff --git a/letta/serialize_schemas/pydantic_agent_schema.py b/letta/serialize_schemas/pydantic_agent_schema.py index a3ab28e3..5cd1805f 100644 --- a/letta/serialize_schemas/pydantic_agent_schema.py +++ b/letta/serialize_schemas/pydantic_agent_schema.py @@ -10,8 +10,6 @@ from letta.schemas.llm_config import LLMConfig class CoreMemoryBlockSchema(BaseModel): created_at: str description: Optional[str] - identities: List[Any] - is_deleted: bool is_template: bool label: str limit: int @@ -42,7 +40,6 @@ class TagSchema(BaseModel): class ToolEnvVarSchema(BaseModel): created_at: str description: Optional[str] - is_deleted: bool key: str updated_at: str value: str @@ -76,7 +73,6 @@ class ToolSchema(BaseModel): args_json_schema: Optional[Any] created_at: str description: str - is_deleted: bool json_schema: ToolJSONSchema name: str return_char_limit: int @@ -94,9 +90,6 @@ class AgentSchema(BaseModel): created_at: str description: Optional[str] embedding_config: EmbeddingConfig - groups: List[Any] - identities: List[Any] - is_deleted: bool llm_config: LLMConfig message_buffer_autoclear: bool messages: List[MessageSchema] diff --git a/tests/test_agent_serialization.py b/tests/test_agent_serialization.py index b2607291..6d8c25c9 100644 --- a/tests/test_agent_serialization.py +++ b/tests/test_agent_serialization.py @@ -351,6 +351,11 @@ def test_append_copy_suffix_simple(local_client, server, serialize_test_agent, d """Test deserializing JSON into an Agent instance.""" result = server.agent_manager.serialize(agent_id=serialize_test_agent.id, actor=default_user) + # write file + with open("test_agent_serialization.json", "w") as f: + # write json + f.write(json.dumps(result.model_dump(), indent=4)) + # Deserialize the agent agent_copy = server.agent_manager.deserialize(serialized_agent=result, actor=other_user, append_copy_suffix=append_copy_suffix)