diff --git a/letta/agent.py b/letta/agent.py index e165b76aea..72fbdb8add 100644 --- a/letta/agent.py +++ b/letta/agent.py @@ -10,6 +10,7 @@ from letta.constants import ( BASE_TOOLS, CLI_WARNING_PREFIX, + ERROR_MESSAGE_PREFIX, FIRST_MESSAGE_ATTEMPTS, FUNC_FAILED_HEARTBEAT_MESSAGE, IN_CONTEXT_MEMORY_KEYWORD, @@ -863,7 +864,7 @@ def _handle_ai_response( return messages, False, True # force a heartbeat to allow agent to handle error # Step 4: check if function response is an error - if function_response_string.startswith("Error"): + if function_response_string.startswith(ERROR_MESSAGE_PREFIX): function_response = package_function_response(False, function_response_string) # TODO: truncate error message somehow messages.append( diff --git a/letta/constants.py b/letta/constants.py index 575b80d7e4..942dd0c903 100644 --- a/letta/constants.py +++ b/letta/constants.py @@ -69,6 +69,8 @@ CLI_WARNING_PREFIX = "Warning: " +ERROR_MESSAGE_PREFIX = "Error" + NON_USER_MSG_PREFIX = "[This is an automated system message hidden from the user] " # Constants to do with summarization / conversation length window diff --git a/letta/utils.py b/letta/utils.py index f8b3778b89..4be8a543fb 100644 --- a/letta/utils.py +++ b/letta/utils.py @@ -28,6 +28,7 @@ CLI_WARNING_PREFIX, CORE_MEMORY_HUMAN_CHAR_LIMIT, CORE_MEMORY_PERSONA_CHAR_LIMIT, + ERROR_MESSAGE_PREFIX, LETTA_DIR, MAX_FILENAME_LENGTH, TOOL_CALL_ID_MAX_LEN, @@ -1122,7 +1123,7 @@ def sanitize_filename(filename: str) -> str: def get_friendly_error_msg(function_name: str, exception_name: str, exception_message: str): from letta.constants import MAX_ERROR_MESSAGE_CHAR_LIMIT - error_msg = f"Error executing function {function_name}: {exception_name}: {exception_message}" + error_msg = f"{ERROR_MESSAGE_PREFIX} executing function {function_name}: {exception_name}: {exception_message}" if len(error_msg) > MAX_ERROR_MESSAGE_CHAR_LIMIT: error_msg = error_msg[:MAX_ERROR_MESSAGE_CHAR_LIMIT] return error_msg