From a61a507967b75a05b43aa6fd2f2bd4e13e133abe Mon Sep 17 00:00:00 2001 From: Matthew Zhou Date: Wed, 6 Nov 2024 17:10:42 -0800 Subject: [PATCH] fix: no error when the tool name is invalid in agent state (#1997) --- letta/server/server.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/letta/server/server.py b/letta/server/server.py index 39baf02a16..35b2e9b05a 100644 --- a/letta/server/server.py +++ b/letta/server/server.py @@ -372,11 +372,12 @@ def _load_agent(self, agent_id: str, actor: User, interface: Union[AgentInterfac logger.debug(f"Creating an agent object") tool_objs = [] for name in agent_state.tools: - tool_obj = self.tool_manager.get_tool_by_name(tool_name=name, actor=actor) - if not tool_obj: - logger.exception(f"Tool {name} does not exist for user {user_id}") - raise ValueError(f"Tool {name} does not exist for user {user_id}") - tool_objs.append(tool_obj) + # TODO: This should be a hard failure, but for migration reasons, we patch it for now + try: + tool_obj = self.tool_manager.get_tool_by_name(tool_name=name, actor=actor) + tool_objs.append(tool_obj) + except NoResultFound: + warnings.warn(f"Tried to retrieve a tool with name {name} from the agent_state, but does not exist in tool db.") # Make sure the memory is a memory object assert isinstance(agent_state.memory, Memory)