Skip to content

ThoughEvent triggers termination via TextMentionTermination #6384

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

Open
yidasanqian opened this issue Apr 24, 2025 · 3 comments
Open

ThoughEvent triggers termination via TextMentionTermination #6384

yidasanqian opened this issue Apr 24, 2025 · 3 comments
Labels
help wanted Extra attention is needed proj-extensions

Comments

@yidasanqian
Copy link

yidasanqian commented Apr 24, 2025

What happened?

Describe the bug
The content with the 'think' tag from Deepseek r1 was sent to the group chat, causing abnormal exit

To Reproduce
Steps to reproduce the behavior. Please include code and outputs such as stacktrace.

code_executor_agent = CodeExecutorAgent(
            name="code_executor", code_executor=code_executor
        )

        assistant_agent = AssistantAgent(
            name="coder_agent",
            model_client=self.model_client,
            system_message=DEFAULT_SYSTEM_MESSAGE,
            model_client_stream=True,
        )

        # The termination condition is a combination of text termination and max message termination, either of which will cause the chat to terminate.
        termination = TextMentionTermination("TERMINATE") | MaxMessageTermination(20)

        # The group chat will alternate between the assistant and the code executor.
        self.group_chat = RoundRobinGroupChat(
            [assistant_agent, code_executor_agent], termination_condition=termination
        )

Expected behavior
Content from the "think" tag should not be sent to group chats.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
terminate prompt:

Only reply with "TERMINATE" at the end of the answer when the specific results from `code_executor` are obtained and all tasks are confirmed to be resolved.

Which packages was the bug in?

Python AgentChat (autogen-agentchat>=0.4.0)

AutoGen library version.

autogen-agentchat==0.5.3
autogen-ext==0.5.3

Other library version.

No response

Model used

deepseek r1

Model provider

OpenRouter/deepseek/siliconflow

Other model provider

No response

Python version

3.12

.NET version

None

Operating system

Windows

@ekzhu
Copy link
Collaborator

ekzhu commented Apr 24, 2025

Could you help us with this one? We don't have access to the model provider you used.

The key is to update the parsing of the result in OpenAIChatCompletionClient (I suppose this is what you are using) to make sure the reasoning content goes to the CreateResult.thought field.

@ekzhu ekzhu added help wanted Extra attention is needed proj-extensions and removed needs-triage labels Apr 24, 2025
@yidasanqian
Copy link
Author

Could you help us with this one? We don't have access to the model provider you used.你能帮我们处理这个吗?我们没有访问你使用的模型提供者的权限。

The key is to update the parsing of the result in OpenAIChatCompletionClient (I suppose this is what you are using) to make sure the reasoning content goes to the CreateResult.thought field.关键是更新 OpenAIChatCompletionClient (我猜这就是您使用的) 中的结果解析,以确保推理内容进入 CreateResult.thought 字段。

It's not for this reason. I suspect that the reasoning content triggers a ThoughtEvent, which leads to the activation of the TextMentionTermination condition.

Image

@ekzhu
Copy link
Collaborator

ekzhu commented Apr 25, 2025

Okay. In that case we can update TextMentionTermination to also specify that we want to skip BaseAgentEvent.

There is also a PR #6398 for using functional expression for termination condition check, for more flexibility

@ekzhu ekzhu changed the title The content with the 'think' tag from Deepseek r1 was sent to the group chat, causing abnormal exit ThoughEvent triggers termination via TextMentionTermination Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed proj-extensions
Projects
None yet
Development

No branches or pull requests

2 participants