cpacker / MemGPT

Letta (fka MemGPT) is a framework for creating stateful LLM services.
https://letta.com
Apache License 2.0
11.49k stars 1.25k forks source link

Error: `First message function call wasn't send_message or archival_memory_search: content=None` when re-loading agent #972

Open sarahwooders opened 7 months ago

sarahwooders commented 7 months ago

Describe the bug I re-loaded an agent after attaching some data, but got this error immediately when running memgpt run again.

Please describe your setup

Screenshots

First message function call wasn't send_message or archival_memory_search: content=None
tool_calls=[ToolCall(id='call_p2QEsO8wJB046uJcZZryaMDD', type='function', function=FunctionCall(arguments='{\n  "content": "The
copyright for \'The Hobbit\' is held by George Allen & Unwin Ltd.",\n  "request_heartbeat": false\n}',
name='archival_memory_insert'))] role='assistant' function_call=None
Using model openai, endpoint: https://api.openai.com/v1
Sending request to https://api.openai.com/v1/chat/completions
response = <Response [200]>
response.json = {'id': 'chatcmpl-8q5CSlFZ1fAXnGK837HMA7ARHR8wR', 'object': 'chat.completion', 'created': 1707423736, 'model':
'gpt-4-0613', 'choices': [{'index': 0, 'message': {'role': 'assistant', 'content': None, 'tool_calls': [{'id':
'call_RNTXGoSbgrV8Q27tp79EZx6K', 'type': 'function', 'function': {'name': 'archival_memory_insert', 'arguments': '{\n  "content":
"The copyright for \'The Hobbit\' is held by George Allen & Unwin Ltd.",\n  "request_heartbeat": false\n}'}}]}, 'logprobs': None,
'finish_reason': 'tool_calls'}], 'usage': {'prompt_tokens': 4576, 'completion_tokens': 41, 'total_tokens': 4617},
'system_fingerprint': None}
First message function call wasn't send_message or archival_memory_search: content=None
tool_calls=[ToolCall(id='call_RNTXGoSbgrV8Q27tp79EZx6K', type='function', function=FunctionCall(arguments='{\n  "content": "The
copyright for \'The Hobbit\' is held by George Allen & Unwin Ltd.",\n  "request_heartbeat": false\n}',
name='archival_memory_insert'))] role='assistant' function_call=None
Using model openai, endpoint: https://api.openai.com/v1
Sending request to https://api.openai.com/v1/chat/completions
response = <Response [200]>
response.json = {'id': 'chatcmpl-8q5CV9RJABQW5axHPERcYs4WPWHQq', 'object': 'chat.completion', 'created': 1707423739, 'model':
'gpt-4-0613', 'choices': [{'index': 0, 'message': {'role': 'assistant', 'content': None, 'tool_calls': [{'id':
'call_pA3O9g1lIKV4MuYiLFaZpvzv', 'type': 'function', 'function': {'name': 'archival_memory_insert', 'arguments': '{\n  "content":
"The copyright for \'The Hobbit\' is held by George Allen & Unwin Ltd.",\n  "request_heartbeat": false\n}'}}]}, 'logprobs': None,
'finish_reason': 'tool_calls'}], 'usage': {'prompt_tokens': 4576, 'completion_tokens': 41, 'total_tokens': 4617},
'system_fingerprint': None}
First message function call wasn't send_message or archival_memory_search: content=None
tool_calls=[ToolCall(id='call_pA3O9g1lIKV4MuYiLFaZpvzv', type='function', function=FunctionCall(arguments='{\n  "content": "The
copyright for \'The Hobbit\' is held by George Allen & Unwin Ltd.",\n  "request_heartbeat": false\n}',
name='archival_memory_insert'))] role='assistant' function_call=None
step() failed
user_message = None
error = Hit first message retry limit (10)
step() failed with an unrecognized exception: 'Hit first message retry limit (10)'
An exception occurred when running agent.step():
Traceback (most recent call last):
  File "/Users/sarahwooders/repos/memgpt-main/MemGPT/memgpt/main.py", line 347, in run_agent_loop
    new_messages, user_message, skip_next_user_input = process_agent_step(user_message, no_verify)
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sarahwooders/repos/memgpt-main/MemGPT/memgpt/main.py", line 323, in process_agent_step
    new_messages, heartbeat_request, function_failed, token_warning, tokens_accumulated = memgpt_agent.step(
                                                                                          ^^^^^^^^^^^^^^^^^^
  File "/Users/sarahwooders/repos/memgpt-main/MemGPT/memgpt/agent.py", line 673, in step
    raise e
  File "/Users/sarahwooders/repos/memgpt-main/MemGPT/memgpt/agent.py", line 602, in step
    raise Exception(f"Hit first message retry limit ({first_message_retry_limit})")
Exception: Hit first message retry limit (10)
hmlatapie commented 7 months ago

I'm seeing what appears to be the same issue on Ubuntu. using chromadb/persistent, sqlite. image

image

Note that token utilization can skyrocket and get very expensive with this error. about $10 per crash in my case. Suggest not doing any agent reloads until this is resolved.

Elliott-Chong commented 7 months ago

Facing this issue as well

louria commented 7 months ago

This happens because verify_first_message_correctness in utils.py enforces certain checks of the1st message response. I ran into this when I told the bot my actual name and the response only includes a core_memory_append function call but no response msg.

Btw, I ran into another error "first message missing internal monologue" when I changed the question to "What is your name".

response.json = {'id': 'chatcmpl-8tc41gCUsvYXVYGVKQf3RUnI9tGcr', 'object': 'chat.completion', 'created': 1708265049,
'model': 'gpt-4-1106-preview', 'choices': [{'index': 0, 'message': {'role': 'assistant', 'content': None, 'tool_calls':
[{'id': 'call_Gmurk9bWTxDMRlM0s69peNO0', 'type': 'function', 'function': {'name': 'send_message', 'arguments': '{"message":"Hello Chad, it\'s nice to connect with you. You can call me ANNA. How are you today?"}'}}]}, 'logprobs':
None, 'finish_reason': 'tool_calls'}], 'usage': {'prompt_tokens': 2650, 'completion_tokens': 36, 'total_tokens': 2686},
'system_fingerprint': 'fp_c3e45ce344'} First message missing internal monologue: content=None tool_calls=[ToolCall(id='call_Gmurk9bWTxDMRlM0s69peNO0', type='function', function=FunctionCall(arguments='{"message":"Hello Chad, it\'s nice to connect with you. You can call me ANNA. How are you today?"}', name='send_message'))] role='assistant' function_call=None

and then hit the 10 tries limit. This is indeed very expensive.

hmlatapie commented 7 months ago

memgpt run with the --no-verify option seems to eliminate the problem. I'm now running memgpt version 0.3.3 on python 3.11.

yoadsn commented 5 months ago

What is the purpose of the verification in the first place? Specifically, why does it make sure there is an internal monologue? The app does that (as stated above) also when the agent is restarted when the conversation is already mid-way. So knowing the purpose for that might help improving this and not blindly applying --no-verify on every restart.