Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: blocks list endpoint bug (#1421)
cthomasec092f694000
diff --git a/letta/server/rest_api/routers/v1/blocks.py b/letta/server/rest_api/routers/v1/blocks.pyindex 22ff8e359..3e88f4ace 100644--- a/letta/server/rest_api/routers/v1/blocks.py+++ b/letta/server/rest_api/routers/v1/blocks.py@@ -18,7 +18,7 @@ router = APIRouter(prefix="/blocks", tags=["blocks"])def list_blocks(# query parameterslabel: Optional[str] = Query(None, description="Labels to include (e.g. human, persona)"),- templates_only: bool = Query(True, description="Whether to include only templates"),+ templates_only: bool = Query(False, description="Whether to include only templates"),name: Optional[str] = Query(None, description="Name of the block"),identity_id: Optional[str] = Query(None, description="Search agents by identifier id"),identifier_keys: Optional[List[str]] = Query(None, description="Search agents by identifier keys"),diff --git a/tests/test_sdk_client.py b/tests/test_sdk_client.pyindex 2790a38f4..927e113d5 100644--- a/tests/test_sdk_client.py+++ b/tests/test_sdk_client.py@@ -592,3 +592,60 @@ def test_agent_creation(client: LettaSDKClient):assert len(agent_tools) == 2tool_ids = {tool1.id, tool2.id}assert all(tool.id in tool_ids for tool in agent_tools)+++def test_many_blocks(client: LettaSDKClient):+ users = ["user1", "user2"]+ # Create agent with the blocks+ agent1 = client.agents.create(+ name=f"test_agent_{str(uuid.uuid4())}",+ memory_blocks=[+ CreateBlock(+ label="user1",+ value="user preferences: loud",+ ),+ CreateBlock(+ label="user2",+ value="user preferences: happy",+ ),+ ],+ model="openai/gpt-4o-mini",+ embedding="openai/text-embedding-ada-002",+ include_base_tools=False,+ tags=["test"],+ )+ agent2 = client.agents.create(+ name=f"test_agent_{str(uuid.uuid4())}",+ memory_blocks=[+ CreateBlock(+ label="user1",+ value="user preferences: sneezy",+ ),+ CreateBlock(+ label="user2",+ value="user preferences: lively",+ ),+ ],+ model="openai/gpt-4o-mini",+ embedding="openai/text-embedding-ada-002",+ include_base_tools=False,+ tags=["test"],+ )++ # Verify the agent was created successfully+ assert agent1 is not None+ assert agent2 is not None++ # Verify all memory blocks are properly attached+ for user in users:+ agent_block = client.agents.blocks.retrieve(agent_id=agent1.id, block_label=user)+ assert agent_block is not None++ blocks = client.blocks.list(label=user)+ assert len(blocks) == 2++ for block in blocks:+ client.blocks.delete(block.id)++ client.agents.delete(agent1.id)+ client.agents.delete(agent2.id)diff --git a/tests/test_v1_routes.py b/tests/test_v1_routes.pyindex 0f12ac4b7..819c0683c 100644--- a/tests/test_v1_routes.py+++ b/tests/test_v1_routes.py@@ -364,7 +364,7 @@ def test_list_blocks(client, mock_sync_server):Test the GET /v1/blocks endpoint to list blocks."""# Arrange: mock return from block_manager- mock_block = Block(label="human", value="Hi", is_template=True)+ mock_block = Block(label="human", value="Hi")mock_sync_server.block_manager.get_blocks.return_value = [mock_block]# Act@@ -378,7 +378,7 @@ def test_list_blocks(client, mock_sync_server):mock_sync_server.block_manager.get_blocks.assert_called_once_with(actor=mock_sync_server.user_manager.get_user_or_default.return_value,label=None,- is_template=True,+ is_template=False,template_name=None,identity_id=None,identifier_keys=None,