Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix(core): fix CI test failures from SDK 1.7.12 version changes (#9892)

Sarah Wooders07b52b8a9391
diff --git a/tests/integration_test_conversations_sdk.py b/tests/integration_test_conversations_sdk.py
index f8508047e..8fe33fde3 100644
--- a/tests/integration_test_conversations_sdk.py
+++ b/tests/integration_test_conversations_sdk.py
@@ -388,8 +388,8 @@ class TestConversationsSDK:
stream = client.conversations.messages.stream(conversation_id=conversation.id)
list(stream) # Consume the stream to trigger the error
- # Should return 400 because no active run exists (run is completed)
- assert "No active runs found" in str(exc_info.value)
+ # Should return 400 because the run was not created in background mode
+ assert "not created in background mode" in str(exc_info.value) or "No active runs found" in str(exc_info.value)
def test_conversation_lock_released_after_completion(self, client: Letta, agent):
"""Test that lock is released after request completes by sending sequential messages."""
diff --git a/tests/integration_test_human_in_the_loop.py b/tests/integration_test_human_in_the_loop.py
index fab4cc147..3b3d225cf 100644
--- a/tests/integration_test_human_in_the_loop.py
+++ b/tests/integration_test_human_in_the_loop.py
@@ -276,11 +276,10 @@ def test_invoke_approval_request(
# Test pending_approval relationship field
agent_with_pending = client.agents.retrieve(agent_id=agent.id, include=["agent.pending_approval"])
assert agent_with_pending.pending_approval is not None
- # Client SDK returns it as a dict, so use dict access
- assert agent_with_pending.pending_approval["tool_call"]["name"] == "get_secret_code_tool"
- assert len(agent_with_pending.pending_approval["tool_calls"]) > 0
- assert agent_with_pending.pending_approval["tool_calls"][0]["name"] == "get_secret_code_tool"
- assert agent_with_pending.pending_approval["tool_calls"][0]["tool_call_id"] == response.messages[-1].tool_call.tool_call_id
+ assert agent_with_pending.pending_approval.tool_call.name == "get_secret_code_tool"
+ assert len(agent_with_pending.pending_approval.tool_calls) > 0
+ assert agent_with_pending.pending_approval.tool_calls[0].name == "get_secret_code_tool"
+ assert agent_with_pending.pending_approval.tool_calls[0].tool_call_id == response.messages[-1].tool_call.tool_call_id
approve_tool_call(client, agent.id, response.messages[-1].tool_call.tool_call_id)
diff --git a/tests/integration_test_sleeptime_agent.py b/tests/integration_test_sleeptime_agent.py
index 1f26550c7..f02fe1569 100644
--- a/tests/integration_test_sleeptime_agent.py
+++ b/tests/integration_test_sleeptime_agent.py
@@ -6,7 +6,7 @@ import pytest
import requests
from dotenv import load_dotenv
from letta_client import APIError, Letta
-from letta_client.types import CreateBlockParam, MessageCreateParam, SleeptimeManagerParam
+from letta_client.types import CreateBlockParam, MessageCreateParam
from letta.constants import DEFAULT_HUMAN
from letta.utils import get_human_text, get_persona_text
@@ -86,21 +86,26 @@ async def test_sleeptime_group_chat(client):
assert "core_memory_replace" not in main_agent_tools
assert "archival_memory_insert" not in main_agent_tools
- # 2. Override frequency for test
- group = client.groups.update(
- group_id=main_agent.multi_agent_group.id,
- manager_config=SleeptimeManagerParam(
- manager_type="sleeptime",
- sleeptime_agent_frequency=2,
- ),
+ # 2. Override frequency for test (groups API deprecated and removed from SDK, use raw HTTP)
+ group_id = main_agent.multi_agent_group.id
+ resp = requests.patch(
+ f"{client.base_url}/v1/groups/{group_id}",
+ json={
+ "manager_config": {
+ "manager_type": "sleeptime",
+ "sleeptime_agent_frequency": 2,
+ }
+ },
)
+ resp.raise_for_status()
+ group = resp.json()
- assert group.manager_type == "sleeptime"
- assert group.sleeptime_agent_frequency == 2
- assert len(group.agent_ids) == 1
+ assert group["manager_type"] == "sleeptime"
+ assert group["sleeptime_agent_frequency"] == 2
+ assert len(group["agent_ids"]) == 1
# 3. Verify shared blocks
- sleeptime_agent_id = group.agent_ids[0]
+ sleeptime_agent_id = group["agent_ids"][0]
shared_block = client.agents.blocks.retrieve(agent_id=main_agent.id, block_label="human")
agents = client.blocks.agents.list(block_id=shared_block.id).items
assert len(agents) == 2
@@ -171,8 +176,6 @@ async def test_sleeptime_group_chat(client):
# 7. Delete agent (now safe because all runs are complete)
client.agents.delete(agent_id=main_agent.id)
- with pytest.raises(APIError):
- client.groups.retrieve(group_id=group.id)
with pytest.raises(APIError):
client.agents.retrieve(agent_id=sleeptime_agent_id)
@@ -199,14 +202,19 @@ async def test_sleeptime_removes_redundant_information(client):
agent_type="letta_v1_agent",
)
- group = client.groups.update(
- group_id=main_agent.multi_agent_group.id,
- manager_config=SleeptimeManagerParam(
- manager_type="sleeptime",
- sleeptime_agent_frequency=1,
- ),
+ group_id = main_agent.multi_agent_group.id
+ resp = requests.patch(
+ f"{client.base_url}/v1/groups/{group_id}",
+ json={
+ "manager_config": {
+ "manager_type": "sleeptime",
+ "sleeptime_agent_frequency": 1,
+ }
+ },
)
- sleeptime_agent_id = group.agent_ids[0]
+ resp.raise_for_status()
+ group = resp.json()
+ sleeptime_agent_id = group["agent_ids"][0]
shared_block = client.agents.blocks.retrieve(agent_id=main_agent.id, block_label="human")
count_before_memory_edits = shared_block.value.count("fiddle leaf")
test_messages = ["hello there", "my favorite bird is the sparrow"]
@@ -232,8 +240,6 @@ async def test_sleeptime_removes_redundant_information(client):
# 4. Delete agent
client.agents.delete(agent_id=main_agent.id)
- with pytest.raises(APIError):
- client.groups.retrieve(group_id=group.id)
with pytest.raises(APIError):
client.agents.retrieve(agent_id=sleeptime_agent_id)
diff --git a/tests/test_client.py b/tests/test_client.py
index b50165a4b..2ffd84331 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -798,11 +798,8 @@ def test_attach_sleeptime_block(client: Letta):
enable_sleeptime=True,
)
- # get the sleeptime agent
- # get the multi-agent group
- group_id = agent.multi_agent_group.id
- group = client.groups.retrieve(group_id=group_id)
- agent_ids = group.agent_ids
+ # get the sleeptime agent from the multi-agent group
+ agent_ids = agent.multi_agent_group.agent_ids
sleeptime_id = next(id for id in agent_ids if id != agent.id)
# attach a new block
diff --git a/tests/test_sdk_client.py b/tests/test_sdk_client.py
index ec749c543..8954c5181 100644
--- a/tests/test_sdk_client.py
+++ b/tests/test_sdk_client.py
@@ -28,7 +28,6 @@ from letta_client.types.tool import BaseTool
from pydantic import BaseModel, Field
from letta.config import LettaConfig
-from letta.jobs.llm_batch_job_polling import poll_running_llm_batches
from letta.server.server import SyncServer
from tests.utils import wait_for_server
@@ -2139,70 +2138,6 @@ def test_run_list(client: LettaSDKClient):
assert run.agent_id == agent.id
-async def test_create_batch(client: LettaSDKClient, server: SyncServer):
- # create agents
- agent1 = client.agents.create(
- name="agent1_batch",
- memory_blocks=[{"label": "persona", "value": "you are agent 1"}],
- model="anthropic/claude-sonnet-4-20250514",
- embedding="openai/text-embedding-3-small",
- )
- agent2 = client.agents.create(
- name="agent2_batch",
- memory_blocks=[{"label": "persona", "value": "you are agent 2"}],
- model="anthropic/claude-sonnet-4-20250514",
- embedding="openai/text-embedding-3-small",
- )
-
- # create a run
- run = client.batches.create(
- requests=[
- {
- "messages": [
- MessageCreateParam(
- role="user",
- content="hi",
- )
- ],
- "agent_id": agent1.id,
- },
- {
- "messages": [
- MessageCreateParam(
- role="user",
- content="hi",
- )
- ],
- "agent_id": agent2.id,
- },
- ]
- )
- assert run is not None
-
- # list batches
- batches = client.batches.list()
- batches_list = list(batches)
- assert len(batches_list) >= 1, f"Expected 1 or more batches, got {len(batches_list)}"
- assert batches_list[0].status == "running"
-
- # Poll it once
- await poll_running_llm_batches(server)
-
- # get the batch results
- results = client.batches.retrieve(
- batch_id=run.id,
- )
- assert results is not None
-
- # cancel
- client.batches.cancel(batch_id=run.id)
- batch_job = client.batches.retrieve(
- batch_id=run.id,
- )
- assert batch_job.status == "cancelled"
-
-
def test_create_agent(client: LettaSDKClient) -> None:
"""Test creating an agent and streaming messages with tokens"""
agent = client.agents.create(