Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
Revert relaxing verify_first_message_correctness, still add archival_memory_search as an exception (#350)
Vivian Fang5b8812c82279
diff --git a/memgpt/agent.py b/memgpt/agent.pyindex ec156e53c..8c5ea6042 100644--- a/memgpt/agent.py+++ b/memgpt/agent.py@@ -466,37 +466,25 @@ class Agent(object):state = json.load(file)self.load_inplace(state)- def verify_first_message_correctness(self, response, require_function_call=True, require_monologue=False):+ def verify_first_message_correctness(self, response, require_send_message=True, require_monologue=False):"""Can be used to enforce that the first message always uses send_message"""response_message = response.choices[0].message# First message should be a call to send_message with a non-empty content- if require_function_call and not response_message.get("function_call"):+ if require_send_message and not response_message.get("function_call"):printd(f"First message didn't include function call: {response_message}")return False- expected_function_calls = [x["name"] for x in self.functions]function_name = response_message["function_call"]["name"]- if require_function_call and function_name not in expected_function_calls:- printd(f"First message function call wasn't one of {expected_function_calls}: {response_message}")+ if require_send_message and function_name != "send_message" and function_name != "archival_memory_search":+ printd(f"First message function call wasn't send_message or archival_memory_search: {response_message}")return Falseif require_monologue and (not response_message.get("content") or response_message["content"] is None or response_message["content"] == ""):- if function_name in expected_function_calls:- try:- raw_function_args = response_message["function_call"]["arguments"]- function_args = parse_json(raw_function_args)- except Exception as e:- printd(f"First message missing internal monologue and has badly formed arguments: {response_message}")- return False- if function_args.get("request_heartbeat") != True:- printd(f"First message missing internal monologue and does not chain further functions: {response_message}")- return False- else:- printd(f"First message missing internal monologue: {response_message}")- return False+ printd(f"First message missing internal monologue: {response_message}")+ return Falseif response_message.get("content"):### Extras