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

Agent name termination #4123

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

thainduy
Copy link

Why are these changes needed?

Introduces the AgentNameTermination class, which is a termination condition for conversations based on last agent name

Related issue number

Checks

@thainduy
Copy link
Author

@microsoft-github-policy-service agree

- Rename class to `SourceMatchTermination`
from autogen_agentchat.messages import StopMessage, AgentMessage


class SourceMatchTermination(TerminationCondition):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. I initially misunderstood the trigger. Since the trigger is the last source mentioned. I am wondering, if we don't need to limit to the last message's source. Any message that matches the source can trigger termination. The scenario I have in mind is that a summary agent finishes responding then the group chat terminates.

What's the scenario you have in mind for the trigger?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same senario. The only difference is allowing the user to start another conversation with the same chat history.
So, in my case, I need to check the last message, but not any message

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The termination condition is applied after the messages have been processed by the agent. So, the chat history is preserved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but if we have chat history from last conversation and then check any message that matches the source, conversation will alway terminate after 1 agent talking even if it's not the summary agent that we wanted. because the summary agent message existed in history

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The termination condition is invoked on the delta since the last time it was invoked rather than the whole history. So it won't see the same message twice.

Copy link
Author

@thainduy thainduy Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, so the messages: Sequence[AgentMessage] param in __call__ function is only come from the last agent and not entire group chat history right? in that case, yes, you was right, we can check any message match the source but i think it would make no difference since all message come from same agent? 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since all message come from same agent? 🤔

When the agents are not nesting another team inside, then yes. But an agent can contain a team, which will produce messages from multiple agents -- when that get sent to the parent team the termination condition will see multiple agents' messages

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right. Sorry, i missed the senario Nested chat. In that scenario, if we check any message to match the source, then this will allow terminate conversation when specific agents are involved in nested chat. Is that what you mean? I think that makes sense.

I can update this logic on the next commit if you want. Please let me know.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Let's change the logic to terminate whenever an agent source is matched.

this will allow terminate conversation when specific agents are involved in nested chat. Is that what you mean?

yes. just to keep it simple, the termination condition in the parent team will be applied on the flattened messages from all agents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants