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.

Clean memory error messages (#523)

Charles Packerf4a1455c247a
diff --git a/memgpt/agent.py b/memgpt/agent.py
index 567e44076..e24bf6e8d 100644
--- a/memgpt/agent.py
+++ b/memgpt/agent.py
@@ -515,10 +515,14 @@ class Agent(object):
try:
function_args["self"] = self # need to attach self to arg since it's dynamically linked
function_response_string = function_to_call(**function_args)
+ function_args.pop("self", None)
function_response = package_function_response(True, function_response_string)
function_failed = False
except Exception as e:
- error_msg = f"Error calling function {function_name} with args {function_args}: {str(e)}"
+ function_args.pop("self", None)
+ # error_msg = f"Error calling function {function_name} with args {function_args}: {str(e)}"
+ # Less detailed - don't provide full args, idea is that it should be in recent context so no need (just adds noise)
+ error_msg = f"Error calling function {function_name}: {str(e)}"
error_msg_user = f"{error_msg}\n{traceback.format_exc()}"
printd(error_msg_user)
function_response = package_function_response(False, error_msg)
diff --git a/memgpt/memory.py b/memgpt/memory.py
index 188e1eb19..d49ac48c3 100644
--- a/memgpt/memory.py
+++ b/memgpt/memory.py
@@ -86,7 +86,7 @@ class CoreMemory(object):
elif field == "human":
return self.edit_human(content)
else:
- raise KeyError
+ raise KeyError(f'No memory section named {field} (must be either "persona" or "human")')
def edit_append(self, field, content, sep="\n"):
if field == "persona":
@@ -96,7 +96,7 @@ class CoreMemory(object):
new_content = self.human + sep + content
return self.edit_human(new_content)
else:
- raise KeyError
+ raise KeyError(f'No memory section named {field} (must be either "persona" or "human")')
def edit_replace(self, field, old_content, new_content):
if field == "persona":
@@ -112,7 +112,7 @@ class CoreMemory(object):
else:
raise ValueError("Content not found in human (make sure to use exact string)")
else:
- raise KeyError
+ raise KeyError(f'No memory section named {field} (must be either "persona" or "human")')
def summarize_messages(