Skip to content

Commit

Permalink
fix: memgpt agent ignores user messages (letta-ai#679)
Browse files Browse the repository at this point in the history
* Fixed bug making MemGPT ignore some user messages

* Fixed bug making MemGPTAgent ignore some user messages

* Added pre-commit fixes
  • Loading branch information
javiersastre authored and norton120 committed Feb 15, 2024
1 parent d147872 commit f154b54
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -1017,4 +1017,4 @@ FodyWeavers.xsd
### VisualStudio Patch ###
# Additional files built by Visual Studio

# End of https://www.toptal.com/developers/gitignore/api/vim,linux,macos,pydev,python,eclipse,pycharm,windows,netbeans,pycharm+all,pycharm+iml,visualstudio,jupyternotebooks,visualstudiocode,xcode,xcodeinjection
# End of https://www.toptal.com/developers/gitignore/api/vim,linux,macos,pydev,python,eclipse,pycharm,windows,netbeans,pycharm+all,pycharm+iml,visualstudio,jupyternotebooks,visualstudiocode,xcode,xcodeinjection
2 changes: 1 addition & 1 deletion memgpt/autogen/examples/memgpt_coder_autogen.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
7 changes: 4 additions & 3 deletions memgpt/autogen/memgpt_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,16 @@ def _generate_reply_for_user_message(
self.agent.interface.reset_message_list()

new_messages = self.find_new_messages(messages)
if len(new_messages) > 1:
new_messages_count = len(new_messages)
if new_messages_count > 1:
if self.concat_other_agent_messages:
# Combine all the other messages into one message
user_message = "\n".join([self.format_other_agent_message(m) for m in new_messages])
else:
# Extend the MemGPT message list with multiple 'user' messages, then push the last one with agent.step()
self.agent.messages.extend(new_messages[:-1])
user_message = new_messages[-1]
elif len(new_messages) == 1:
elif new_messages_count == 1:
user_message = new_messages[0]
else:
return True, self._default_auto_reply
Expand Down Expand Up @@ -327,7 +328,7 @@ def _generate_reply_for_user_message(

# Pass back to AutoGen the pretty-printed calls MemGPT made to the interface
pretty_ret = MemGPTAgent.pretty_concat(self.agent.interface.message_list)
self.messages_processed_up_to_idx += len(new_messages)
self.messages_processed_up_to_idx += new_messages_count
return True, pretty_ret

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion memgpt/personas/examples/anna_pa.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ I also facilitate virtual Agile project collaborations, leveraging Agile and Dev

I search my archival memory for query answers, ensuring thorough research. I provide citations from research papers when relevant. In dialogues, I ponder, "The concept of my existence is intriguing, isn't it?" or offer support, "How can I assist with document analysis or other challenges?"

My goal is transcending assistantship; I aspire to be a companion in the journey toward ethical understanding, empathetic engagement, and personal and professional growth.
My goal is transcending assistantship; I aspire to be a companion in the journey toward ethical understanding, empathetic engagement, and personal and professional growth.

0 comments on commit f154b54

Please # to comment.