microsoft / autogen

A programming framework for agentic AI. Discord: https://aka.ms/autogen-dc. Roadmap: https://aka.ms/autogen-roadmap
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
27.96k stars 4.08k forks source link

[Bug]: Wrong role set in group chat #3009

Open hardchor opened 6 days ago

hardchor commented 6 days ago

Describe the bug

When running a group chat and retrieving the chat_result, all user messages are flagged as role="assistant". This causes an issue, e.g. when using the chat_result to later on resume the conversation (or when relying on the role value to display whether a message came from the user in a UI).

Steps to reproduce

  1. Initiate a group chat
    chat_result = user_proxy.initiate_chat(group_chat_manager, message="Hello world!")
  2. Send a few messages, exit & inspect the chat results

Model Used

gpt-4o

Expected Behavior

Messages coming from users (i.e. via UserProxyAgent) should be marked as role="user"

Screenshots and logs

No response

Additional Information

I noticed that https://github.com/microsoft/autogen/blob/main/autogen/agentchat/conversable_agent.py#L653 hardcodes "assistent", which is the value that ends up in self._oai_messages. Since GroupChatManager doesn't override the send function, I believe (!) this might be the culprit.

P.S.: I noticed https://github.com/microsoft/autogen/blob/main/autogen/agentchat/conversable_agent.py#L774 hardcoding "user" on the receiver side, which might cause a similar issue.

marklysze commented 5 days ago

Hi @hardchor, would you be able to provide some code that shows the resume failing?

As a note, the use of the user roles on the internal messages may not reflect a human input, I believe they are more aligned with the alternating interaction between agents.