chore: Deprecate agent file v1 related things [LET-4500] (#4902)
Deprecate agent file v1 related things
This commit is contained in:
committed by
Caren Thomas
parent
daa056d638
commit
462d37813e
1
.github/workflows/core-unit-sqlite-test.yaml
vendored
1
.github/workflows/core-unit-sqlite-test.yaml
vendored
@@ -42,7 +42,6 @@ jobs:
|
||||
{"test_suite": "test_memory.py"},
|
||||
{"test_suite": "test_utils.py"},
|
||||
{"test_suite": "test_stream_buffer_readers.py"},
|
||||
{"test_suite": "test_agent_serialization.py"},
|
||||
{"test_suite": "test_optimistic_json_parser.py"},
|
||||
{"test_suite": "test_llm_clients.py"},
|
||||
{"test_suite": "test_letta_agent_batch.py"},
|
||||
|
||||
1
.github/workflows/core-unit-test.yml
vendored
1
.github/workflows/core-unit-test.yml
vendored
@@ -43,7 +43,6 @@ jobs:
|
||||
{"test_suite": "test_memory.py"},
|
||||
{"test_suite": "test_utils.py"},
|
||||
{"test_suite": "test_stream_buffer_readers.py"},
|
||||
{"test_suite": "test_agent_serialization.py"},
|
||||
{"test_suite": "test_agent_serialization_v2.py"},
|
||||
{"test_suite": "test_optimistic_json_parser.py"},
|
||||
{"test_suite": "test_llm_clients.py"},
|
||||
|
||||
@@ -386,15 +386,9 @@ async def import_agent(
|
||||
)
|
||||
else:
|
||||
# This is a legacy AgentSchema
|
||||
agent_ids = import_agent_legacy(
|
||||
agent_json=agent_json,
|
||||
server=server,
|
||||
actor=actor,
|
||||
append_copy_suffix=append_copy_suffix,
|
||||
override_existing_tools=override_existing_tools,
|
||||
project_id=project_id,
|
||||
strip_messages=strip_messages,
|
||||
env_vars=env_vars,
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="Legacy AgentSchema format is deprecated. Please use the new AgentFileSchema format with 'agents' field.",
|
||||
)
|
||||
|
||||
return ImportedAgentsResponse(agent_ids=agent_ids)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import difflib
|
||||
import json
|
||||
import os
|
||||
@@ -72,12 +73,15 @@ def server_url() -> str:
|
||||
|
||||
|
||||
def _clear_tables():
|
||||
from letta.server.db import db_context
|
||||
from letta.server.db import db_registry
|
||||
|
||||
with db_context() as session:
|
||||
for table in reversed(Base.metadata.sorted_tables): # Reverse to avoid FK issues
|
||||
session.execute(table.delete()) # Truncate table
|
||||
session.commit()
|
||||
async def _clear():
|
||||
async with db_registry.async_session() as session:
|
||||
for table in reversed(Base.metadata.sorted_tables): # Reverse to avoid FK issues
|
||||
await session.execute(table.delete()) # Truncate table
|
||||
await session.commit()
|
||||
|
||||
asyncio.run(_clear())
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@@ -112,14 +116,22 @@ def default_user(server: SyncServer, default_organization):
|
||||
@pytest.fixture
|
||||
def other_organization(server: SyncServer):
|
||||
"""Fixture to create and return the default organization."""
|
||||
org = server.organization_manager.create_organization(pydantic_org=Organization(name="letta"))
|
||||
|
||||
async def create_org():
|
||||
return await server.organization_manager.create_organization_async(pydantic_org=Organization(name="letta"))
|
||||
|
||||
org = asyncio.run(create_org())
|
||||
yield org
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def other_user(server: SyncServer, other_organization):
|
||||
"""Fixture to create and return the default user within the default organization."""
|
||||
user = server.user_manager.create_user(pydantic_user=User(organization_id=other_organization.id, name="sarah"))
|
||||
|
||||
async def create_user():
|
||||
return await server.user_manager.create_actor_async(pydantic_user=User(organization_id=other_organization.id, name="sarah"))
|
||||
|
||||
user = asyncio.run(create_user())
|
||||
yield user
|
||||
|
||||
|
||||
|
||||
@@ -1487,18 +1487,14 @@ class TestAgentFileEdgeCases:
|
||||
actor=default_user,
|
||||
)
|
||||
|
||||
# Add many messages
|
||||
for i in range(10):
|
||||
num_messages = 5
|
||||
|
||||
for i in range(num_messages):
|
||||
await send_message_to_agent(server, agent_state, default_user, [MessageCreate(role=MessageRole.user, content=f"Message {i}")])
|
||||
|
||||
# Export
|
||||
agent_file = await agent_serialization_manager.export([agent_state.id], default_user)
|
||||
|
||||
# Verify large file
|
||||
exported_agent = agent_file.agents[0]
|
||||
assert len(exported_agent.messages) >= 10
|
||||
|
||||
# Import
|
||||
assert len(exported_agent.messages) >= num_messages
|
||||
result = await agent_serialization_manager.import_file(agent_file, other_user)
|
||||
|
||||
# Verify all messages imported correctly
|
||||
@@ -1506,7 +1502,7 @@ class TestAgentFileEdgeCases:
|
||||
imported_agent_id = next(db_id for file_id, db_id in result.id_mappings.items() if file_id == "agent-0")
|
||||
imported_messages = await server.message_manager.list_messages_for_agent_async(imported_agent_id, other_user)
|
||||
|
||||
assert len(imported_messages) >= 10
|
||||
assert len(imported_messages) >= num_messages
|
||||
|
||||
|
||||
class TestAgentFileValidation:
|
||||
|
||||
Reference in New Issue
Block a user