From bd2b7dc6d4a1a442471daa76dd224ff7a85ca216 Mon Sep 17 00:00:00 2001 From: Matthew Zhou Date: Wed, 4 Jun 2025 12:01:05 -0700 Subject: [PATCH] feat: Add catch for empty system message (#2622) --- letta/services/agent_manager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/letta/services/agent_manager.py b/letta/services/agent_manager.py index 1a7b60ab..41bc5b35 100644 --- a/letta/services/agent_manager.py +++ b/letta/services/agent_manager.py @@ -1384,6 +1384,11 @@ class AgentManager: curr_system_message = self.get_system_message( agent_id=agent_id, actor=actor ) # this is the system + memory bank, not just the system prompt + + if curr_system_message is None: + logger.warning(f"No system message found for agent {agent_state.id} and user {actor}") + return agent_state + curr_system_message_openai = curr_system_message.to_openai_dict() # note: we only update the system prompt if the core memory is changed @@ -1451,6 +1456,11 @@ class AgentManager: curr_system_message = await self.get_system_message_async( agent_id=agent_id, actor=actor ) # this is the system + memory bank, not just the system prompt + + if curr_system_message is None: + logger.warning(f"No system message found for agent {agent_state.id} and user {actor}") + return agent_state + curr_system_message_openai = curr_system_message.to_openai_dict() # note: we only update the system prompt if the core memory is changed