diff --git a/memgpt/agent.py b/memgpt/agent.py index 567e440761..e24bf6e8d7 100644 --- a/memgpt/agent.py +++ b/memgpt/agent.py @@ -515,10 +515,14 @@ def handle_ai_response(self, response_message): 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 188e1eb19c..d49ac48c32 100644 --- a/memgpt/memory.py +++ b/memgpt/memory.py @@ -86,7 +86,7 @@ def edit(self, field, content): 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 @@ def edit_append(self, field, content, sep="\n"): 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 @@ def edit_replace(self, field, old_content, new_content): 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(