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

[Python] Termination on Agent Selection #5335

Open
ekzhu opened this issue Feb 3, 2025 · 0 comments
Open

[Python] Termination on Agent Selection #5335

ekzhu opened this issue Feb 3, 2025 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation proj-agentchat
Milestone

Comments

@ekzhu
Copy link
Collaborator

ekzhu commented Feb 3, 2025

The group chat can just terminate when an agent is selected as the speaker. It could be done by having the group chat exposes a SpeakerSelectedEvent and add a new termination condition, NextSpeakerMatchTermination, that terminates the group chat when a SpeakerSelectedEvent emitts with a matching spaker.

For Context: #5324 (comment)_

For Swarm group chat, you can use HandoffTermination to terminate the run and restart it with your user input as the next task. You can read about it in this example: https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/swarm.html#customer-support-example.

You can also use HandoffTermination for SelectorGroupChat, it also requires the agent to be able to use the handoff feature: https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/tutorial/human-in-the-loop.html#using-termination-conditions.

The use of HandoffTermination means you don't use UserProxyAgent in a group chat, you stop the group chat, give the control back to the applicaiton, and restart it with a new message. The state of the group chat is maintained in memory, or persisted using save_state and load_state.


If for some reason, you must use UserProxyAgent with a UI (e.g., your model doesn't support function calling), then your application must be asynchronous. In the input callback of UserProxyAgent, you need to send a message to the frontend, wait on a specific asyncio.Event, when the user message arrives back in a separate coroutine or your fast api handler, you set the asyncio.Event, and obtain the message to be used as response.

If the above sound too complicated to you -- I agree, and I think there should be a more elegant way to address this scenario for SelectorGroupChat and RoundRobinGroupChat when function calling model is not available.

One idea is to have the group chat just terminate when user proxy is selected as the speaker. It could be done by having the group chat exposes a SpeakerSelectedEvent and add a new termination condition, NextSpeakerMatchTermination, that terminates the group chat when a SpeakerSelectedEvent emitts with a matching spaker.

Originally posted by @ekzhu in #5324 (comment)

@ekzhu ekzhu added proj-agentchat documentation Improvements or additions to documentation and removed needs-triage documentation Improvements or additions to documentation labels Feb 3, 2025
@ekzhu ekzhu added this to the python-v0.4.6 milestone Feb 3, 2025
@ekzhu ekzhu marked this as a duplicate and then as not a duplicate of #5220 Feb 3, 2025
@ekzhu ekzhu changed the title Termination on Agent Selection [Python] Termination on Agent Selection Feb 3, 2025
@ekzhu ekzhu self-assigned this Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation proj-agentchat
Projects
None yet
Development

No branches or pull requests

1 participant