Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
Revert "fix: Resync agents when tools are missing" (#1996)
Sarah Woodersd64e09aff6f7
diff --git a/letta/server/server.py b/letta/server/server.pyindex 678d99a66..39baf02a1 100644--- a/letta/server/server.py+++ b/letta/server/server.py@@ -372,12 +372,11 @@ class SyncServer(Server):logger.debug(f"Creating an agent object")tool_objs = []for name in agent_state.tools:- # 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.")+ 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)# Make sure the memory is a memory objectassert isinstance(agent_state.memory, Memory)@@ -392,11 +391,6 @@ class SyncServer(Server):# Add the agent to the in-memory store and return its referencelogger.debug(f"Adding agent to the agent cache: user_id={user_id}, agent_id={agent_id}")self._add_agent(user_id=user_id, agent_id=agent_id, agent_obj=letta_agent)-- # if the length of tool_objs does not equal the length of agent_state.tools- # then we need to resync the agent_state to the db to prevent further errors- save_agent(letta_agent, self.ms)-return letta_agentexcept Exception as e: