Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow resetting Society of Mind agent even if it hasn't been run before #5366

Open
gagb opened this issue Feb 4, 2025 · 0 comments
Open
Assignees
Milestone

Comments

@gagb
Copy link
Collaborator

gagb commented Feb 4, 2025

What happened?

Currently if you call on_reset on a society of mind agent before .run() it will raise an error suggesting that the group chat needs to be initialized before it can be reset. @ekzhu and I discussed that this behavior is a bug.

Image

What did you expect to happen?

no bugs

How can we reproduce it (as minimally and precisely as possible)?

Adapted from https://microsoft.github.io/autogen/stable/reference/python/autogen_agentchat.agents.html#autogen_agentchat.agents.SocietyOfMindAgent

import asyncio
from autogen_agentchat.messages import TextMessage
from autogen_agentchat.agents import AssistantAgent, SocietyOfMindAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.conditions import TextMentionTermination


async def main() -> None:
    model_client = OpenAIChatCompletionClient(model="gpt-4o")

    agent1 = AssistantAgent("assistant1", model_client=model_client, system_message="You are a writer, write well.")
    agent2 = AssistantAgent(
        "assistant2",
        model_client=model_client,
        system_message="You are an editor, provide critical feedback. Respond with 'APPROVE' if the text addresses all feedbacks.",
    )
    inner_termination = TextMentionTermination("APPROVE")
    inner_team = RoundRobinGroupChat([agent1, agent2], termination_condition=inner_termination)

    society_of_mind_agent = SocietyOfMindAgent("society_of_mind", team=inner_team, model_client=model_client)

    await society_of_mind_agent.on_reset(cancellation_token=None)

    result = await society_of_mind_agent.on_messages(messages=[
        TextMessage(source="user", content="I am a writer.")
        ], 
        cancellation_token=None
    )
    print(result)


if __name__ == "__main__":
    asyncio.run(main())

AutoGen version

0.4.5

Which package was this bug in

AgentChat

Model used

gpt-4o

Python version

No response

Operating system

No response

Any additional info you think would be helpful for fixing this bug

No response

@ekzhu ekzhu added this to the python-v0.4.x milestone Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants