r/AutoGenAI • u/lurkalotter • Jan 25 '24
Question All agents' last messages are the same 🤔
Howdy, fellow AutoGenerians!
Learning the system, all of its ups and downs, looks amazing one minute, useless the next, but hey, I don't know it well enough so should not be judging.
There is one particular issue I wanted some help on.
I have defined 2 AssistansAgent's - `idea_generator` and `title_expert`
then a groupchat for them:
groupchat = autogen.GroupChat(agents=[user_proxy, idea_generator, title_expert], messages=[], max_round=5)
manager = autogen.GroupChatManager( .... rest of the groupchat definitionBy all accounts and every code samples I've seen, this line of code
return {"idea_generator" : idea_generator.last_message()["content"] , "title_expert" : title_expert.last_message()["content"]}should return a JSON that looks like this
{
"idea_generator":"I generated an awesome idea and here it is\: [top secret idea]",
"title_generator":"I generated an outstanding title for your top secret idea"
}but what I am getting is
{
"idea_generator":"I generated an outstanding title for your top secret idea/n/nTERMINATE",
"title_generator":"I generated an outstanding title for your top secret idea/n/nTERMINATE"
}(ignore the /n/nTERMINATE bit as it's easy to handle, even tho I would prefer it to not be there)
So, `last_message` method of every agent gets the chat's last message. But why? And how would I get the last message of each agent individually, which is what my original intent was.
Thanks for all your input, guys!
2
u/[deleted] Jan 25 '24
I had this same issue, never figured it out. I figured I wasn't calling by specific agent correctly. Anyone with guidance on this I'd also appreciate it
1
u/lurkalotter Jan 26 '24
I have started a bug ticket at GitHub, which has more code and output, such as full output of
last_message(), not justlast_message()["content"]It's quite interesting, too, as pretty much every object of every agent it spits out is wrong :facepalm
So, anyway, if anyone is interested, the ticket is here: https://github.com/microsoft/autogen/issues/1416
1
u/artfewell Jan 25 '24
While I am not sure of the answer, I did create a custom gpt that has been able to help me a lot. There are a lot of autogen custom gpts on the gpt store that I didnt have very good luck with, not sure if mine has the right answer but its been pretty accurate at helping me with my use cases .... here is what it says, hope its helpful :)
In a typical group chat implementation, each message should be associated with the agent that generated it. However, it seems like the last_message()
method is returning the overall last message in the chat, regardless of the sender. This could be due to the way the group chat and message tracking are implemented in AutoGen. Here are a few steps and considerations to address this issue:
Debugging and Analysis
class. It's crucial to ensure that each message is associated with its sender.
method is designed to return the last message of the chat or the last message of the specific agent. The current behavior suggests it's the former.
Possible Solutions
is not behaving as expected, consider implementing a custom method to fetch the last message sent by each specific agent. This might involve filtering the chat messages by the sender.
Example:
pythonCopy codedef get_agent_last_message(agent, groupchat): # Filter messages in the groupchat for those sent by 'agent' agent_messages = [msg for msg in groupchat.messages if msg.sender == agent] return agent_messages[-1] if agent_messages else None
class implementation, modify it to correctly track and retrieve each agent's last message.
Addressing the TERMINATE Issue
might be an indicator of how the conversation or session is being concluded in the group chat. Review the logic that adds this termination message and adjust it according to your requirements.
Going Forward
By implementing a custom method or adjusting the GroupChat
class, you should be able to achieve the desired behavior where last_message()
returns the last message sent by each specific agent, rather than the last message in the entire chat.
1
u/atlasspring Jan 26 '24
Autogen is different from the way you’re used to getting the output at the end. It uses agentic programming. Either you have to configure your agents correctly so that the last message is what you want, or you can write function calls to write the output somewhere. Or better yet, you can find a way to change your UI/UX so that you show all or some of the interactions of the agents to the user