microsoft / autogen

A programming framework for agentic AI 🤖
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
34.65k stars 5.01k forks source link

SelectorGroupChat ignores selector function randomly. #4289

Closed BenConstable9 closed 17 hours ago

BenConstable9 commented 1 day ago

What happened?

I have a multi agent system using selector group chat in v0.4. I have a customer selector functions. I can see from the logs, sometimes it gets called, where as sometimes after an agent invocation, it is not called again.

These agents have tools available to them. I can see from the logs that one agent is stuck in a loop where the group chat manager keeps calling it.

What did you expect to happen?

The selector function is always called after each agent invocation.

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

def text_2_sql_generator_selector_func(messages):
    logging.info("Messages: %s", messages)

termination = TextMentionTermination("TERMINATE") | MaxMessageTermination(10)
generator = SelectorGroupChat(
    [
        QUERY_AGENT,
        REVISE_AGENT,
        TEST_AGENT
    ],
    allow_repeated_speaker=False,
    model_client=<model>,
    termination_condition=termination,
    selector_func=selector_function,
)

AutoGen version

v0.4

Which package was this bug in

AgentChat

Model used

gpt-4o-mini

Python version

No response

Operating system

No response

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

No response

ekzhu commented 1 day ago

@BenConstable9 if the selector function doesn't return a value then the model will be used as a backup.

https://microsoft.github.io/autogen/dev/reference/python/autogen_agentchat/autogen_agentchat.teams.html#autogen_agentchat.teams.SelectorGroupChat

BenConstable9 commented 1 day ago

@ekzhu I have this scenario but I can see from the logs that the selector isn't called in the first place.

I am logging the result that the selector returns and from the logs, I can see it isn't always called after each agent.

ekzhu commented 22 hours ago

I am sorry but the code you provided the selector function doesn't return a value.

You probably need to debug into the framework a bit if providing code isn't an option.

BenConstable9 commented 17 hours ago

Closing after discussion internally