Skip to content

Commit

Permalink
fix: no error when the tool name is invalid in agent state (#1997)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattzh72 authored Nov 7, 2024
1 parent b529588 commit a61a507
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions letta/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a61a507

Please sign in to comment.