Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: sleeptime input locking (#1874)
cthomas8f288ef573ee
diff --git a/letta/groups/sleeptime_multi_agent.py b/letta/groups/sleeptime_multi_agent.pyindex 1eb1e8e3a..6114c5529 100644--- a/letta/groups/sleeptime_multi_agent.py+++ b/letta/groups/sleeptime_multi_agent.py@@ -43,24 +43,21 @@ class SleeptimeMultiAgent(Agent):def _run_async_in_new_thread(self, coro):"""Run an async coroutine in a new thread with its own event loop"""- result = Nonedef run_async():- nonlocal resultloop = asyncio.new_event_loop()asyncio.set_event_loop(loop)try:- result = loop.run_until_complete(coro)+ loop.run_until_complete(coro)finally:loop.close()asyncio.set_event_loop(None)thread = threading.Thread(target=run_async)+ thread.daemon = Truethread.start()- thread.join()- return result- async def _issue_background_task(+ def _issue_background_task(self,participant_agent_id: str,messages: List[Message],@@ -81,7 +78,7 @@ class SleeptimeMultiAgent(Agent):)run = self.job_manager.create_job(pydantic_job=run, actor=self.user)- asyncio.create_task(+ self._run_async_in_new_thread(self._perform_background_agent_step(participant_agent_id=participant_agent_id,messages=messages,@@ -239,17 +236,15 @@ class SleeptimeMultiAgent(Agent):)for participant_agent_id in self.agent_ids:try:- run_id = self._run_async_in_new_thread(- self._issue_background_task(- participant_agent_id,- last_response_messages,- chaining,- max_chaining_steps,- token_streaming,- metadata,- put_inner_thoughts_first,- last_processed_message_id,- )+ run_id = self._issue_background_task(+ participant_agent_id,+ last_response_messages,+ chaining,+ max_chaining_steps,+ token_streaming,+ metadata,+ put_inner_thoughts_first,+ last_processed_message_id,)run_ids.append(run_id)diff --git a/tests/integration_test_sleeptime_agent.py b/tests/integration_test_sleeptime_agent.pyindex f5c3977d8..6b373d049 100644--- a/tests/integration_test_sleeptime_agent.py+++ b/tests/integration_test_sleeptime_agent.py@@ -150,11 +150,14 @@ async def test_sleeptime_group_chat(server, actor):runs = [Run.from_job(job) for job in jobs]agent_runs = [run for run in runs if "agent_id" in run.metadata and run.metadata["agent_id"] == sleeptime_agent_id]assert len(agent_runs) == len(run_ids)++ # 6. Verify run status after sleep+ time.sleep(8)for run_id in run_ids:job = server.job_manager.get_job_by_id(job_id=run_id, actor=actor)assert job.status == JobStatus.completed- # 6. Delete agent+ # 7. Delete agentserver.agent_manager.delete_agent(agent_id=main_agent.id, actor=actor)with pytest.raises(NoResultFound):