Skip to content

Commit

Permalink
add constant for error message prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Caren Thomas committed Dec 20, 2024
1 parent 516d80d commit a595374
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion letta/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions letta/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion letta/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

0 comments on commit a595374

Please sign in to comment.