Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: use labels for error messages for builtin memory tools [LET-7095] (#8941)

Ari Webb5645ca8107aa
diff --git a/letta/services/tool_executor/core_tool_executor.py b/letta/services/tool_executor/core_tool_executor.py
index 24fea8d12..73b934a2e 100644
--- a/letta/services/tool_executor/core_tool_executor.py
+++ b/letta/services/tool_executor/core_tool_executor.py
@@ -11,6 +11,7 @@ from letta.constants import (
from letta.helpers.json_helpers import json_dumps
from letta.helpers.tpuf_client import should_use_tpuf_for_messages
from letta.log import get_logger
+from letta.orm.errors import NoResultFound
from letta.schemas.agent import AgentState
from letta.schemas.block import BlockUpdate
from letta.schemas.enums import MessageRole, TagMatchMode
@@ -834,6 +835,9 @@ class LettaCoreToolExecutor(ToolExecutor):
return f"Successfully deleted memory block '{label}'"
+ except NoResultFound:
+ # Catch the specific error and re-raise with human-readable names
+ raise ValueError(f"Memory block '{label}' is not attached to agent '{agent_state.name}'")
except Exception as e:
return f"Error performing delete: {str(e)}"
@@ -854,6 +858,9 @@ class LettaCoreToolExecutor(ToolExecutor):
return f"Successfully updated description of memory block '{label}'"
+ except NoResultFound:
+ # Catch the specific error and re-raise with human-readable names
+ raise ValueError(f"Memory block '{label}' not found for agent '{agent_state.name}'")
except Exception as e:
raise Exception(f"Error performing update_description: {str(e)}")
@@ -874,6 +881,9 @@ class LettaCoreToolExecutor(ToolExecutor):
return f"Successfully renamed memory block '{old_label}' to '{new_label}'"
+ except NoResultFound:
+ # Catch the specific error and re-raise with human-readable names
+ raise ValueError(f"Memory block '{old_label}' not found for agent '{agent_state.name}'")
except Exception as e:
raise Exception(f"Error performing rename: {str(e)}")