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

SelectorGroupChat example does not work with o3-mini #5408

Open
afourney opened this issue Feb 6, 2025 · 12 comments · May be fixed by #5657
Open

SelectorGroupChat example does not work with o3-mini #5408

afourney opened this issue Feb 6, 2025 · 12 comments · May be fixed by #5657
Assignees
Milestone

Comments

@afourney
Copy link
Member

afourney commented Feb 6, 2025

What happened?

SelectorGroupChat example does not work with o3-mini. The prompt we use has the agent very eager to TERMINATE after 1 round of thinking.

https://microsoft.github.io/autogen/stable//user-guide/agentchat-user-guide/selector-group-chat.html

Image

What did you expect to happen?

For it to work like GPT-4o

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

Run the example, but change the model to o3-mini

AutoGen version

0.4.5

Which package was this bug in

AgentChat

Model used

o3-mini

Python version

No response

Operating system

No response

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

No response

@ekzhu
Copy link
Collaborator

ekzhu commented Feb 7, 2025

Text-based termination is too brittle. Likely we need some other verifiers to ensure behavior.

Currently, we can advice that if a task is not completed, just run the team again with a new prompt to continue.

@afourney
Copy link
Member Author

afourney commented Feb 7, 2025

Text-based termination is too brittle. Likely we need some other verifiers to ensure behavior.

Currently, we can advice that if a task is not completed, just run the team again with a new prompt to continue.

Agreed. Maybe we just change the example slightly somehow.

@spirosoik
Copy link

+1 with o3-mini I have a similar issue.

@ekzhu
Copy link
Collaborator

ekzhu commented Feb 11, 2025

@spirosoik have you tried to update the system message for the planner agent?

Alternatively, I think you don't need to use a planner agent if your model is o3-mini. Remove the planner agent, and make sure you have customized your selector prompt following the latest documentation.

@spirosoik
Copy link

@ekzhu I am following this https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/selector-group-chat.html which is confusing even with the selector prompt.

Honestly what I did is to keep it as is without terminate in text and implement a a Judge agent who approves accordingly or not.

@ekzhu
Copy link
Collaborator

ekzhu commented Feb 11, 2025

Hmm okay. Looks like for o3 mini and reasoning models we need a different type of pattern.

Why is it confusing can you elaborate? How can the doc be improved? Besides changing the pattern.

@mwarqee
Copy link

mwarqee commented Feb 12, 2025

Second this but with o1-mini - I get an error

BadRequestError                           Traceback (most recent call last)
Cell In[4], [line 25](vscode-notebook-cell:?execution_count=4&line=25)
     [19](vscode-notebook-cell:?execution_count=4&line=19) termination = TextMentionTermination("TERMINATE")
     [20](vscode-notebook-cell:?execution_count=4&line=20) team = SelectorGroupChat(
     [21](vscode-notebook-cell:?execution_count=4&line=21)         [categorizer_agent, reviewer_agent],
     [22](vscode-notebook-cell:?execution_count=4&line=22)         model_client=model_client,
     [23](vscode-notebook-cell:?execution_count=4&line=23)         termination_condition=termination,
     [24](vscode-notebook-cell:?execution_count=4&line=24)     )
---> [25](vscode-notebook-cell:?execution_count=4&line=25) await Console(team.run_stream(task=selector_prompt))
     [28](vscode-notebook-cell:?execution_count=4&line=28) print("Team defined successfully with categorizer_agent and reviewer_agent.")  

File c:\Projects\AutoGenStudio\.vcagent\Lib\site-packages\autogen_agentchat\ui\_console.py:49, in Console(stream, no_inline_images)
     [45](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/autogen_agentchat/ui/_console.py:45) total_usage = RequestUsage(prompt_tokens=0, completion_tokens=0)
     [47](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/autogen_agentchat/ui/_console.py:47) last_processed: Optional[T] = None
---> [49](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/autogen_agentchat/ui/_console.py:49) async for message in stream:
     [50](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/autogen_agentchat/ui/_console.py:50)     if isinstance(message, TaskResult):
     [51](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/autogen_agentchat/ui/_console.py:51)         duration = time.time() - start_time

File c:\Projects\AutoGenStudio\.vcagent\Lib\site-packages\autogen_agentchat\teams\_group_chat\_base_group_chat.py:404, in BaseGroupChat.run_stream(self, task, cancellation_token)
    [398](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/autogen_agentchat/teams/_group_chat/_base_group_chat.py:398) shutdown_task = asyncio.create_task(stop_runtime())
    [400](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/autogen_agentchat/teams/_group_chat/_base_group_chat.py:400) try:
    [401](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/autogen_agentchat/teams/_group_chat/_base_group_chat.py:401)     # Run the team by sending the start message to the group chat manager.
    [402](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/autogen_agentchat/teams/_group_chat/_base_group_chat.py:402)     # The group chat manager will start the group chat by relaying the message to the participants
    [403](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/autogen_agentchat/teams/_group_chat/_base_group_chat.py:403)     # and the closure agent.
...
   (...)
   [1652](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/openai/_base_client.py:1652)     retries_taken=retries_taken,
   [1653](file:///C:/Projects/AutoGenStudio/.vcagent/Lib/site-packages/openai/_base_client.py:1653) )


BadRequestError: Error code: 400 - {'error': {'message': "Unsupported value: 'messages[0].role' does not support 'system' with this model.", 'type': 'invalid_request_error', 'param': 'messages[0].role', 'code': 'unsupported_value'}

The o family does not support system messages but developer messages.

@afourney
Copy link
Member Author

afourney commented Feb 12, 2025

Second this but with o1-mini - I get an error

BadRequestError                           Traceback (most recent call last)
Cell In[4], [line 25](vscode-notebook-cell:?execution_count=4&line=25)
     [19](vscode-notebook-cell:?execution_count=4&line=19) termination = TextMentionTermination("TERMINATE")
     [20](vscode-notebook-cell:?execution_count=4&line=20) team = SelectorGroupChat(
     [21](vscode-notebook-cell:?execution_count=4&line=21)         [categorizer_agent, reviewer_agent],
     [22](vscode-notebook-cell:?execution_count=4&line=22)         model_client=model_client,
     [23](vscode-notebook-cell:?execution_count=4&line=23)         termination_condition=termination,
     [24](vscode-notebook-cell:?execution_count=4&line=24)     )
---> [25](vscode-notebook-cell:?execution_count=4&line=25) await Console(team.run_stream(task=selector_prompt))
     [28](vscode-notebook-cell:?execution_count=4&line=28) print("Team defined successfully with categorizer_agent and reviewer_agent.")  
...

BadRequestError: Error code: 400 - {'error': {'message': "Unsupported value: 'messages[0].role' does not support 'system' with this model.", 'type': 'invalid_request_error', 'param': 'messages[0].role', 'code': 'unsupported_value'}

The o family does not support system messages but developer messages.

Are you using OpenAI or Azure? On OpenAI o1 and o3-mini support system messages by simply treating them as developer messages. The OpenAI documentation lists them as aliases.

I just checked, and o1-mini does not support developer OR system messages. It acts more like the o1-preview model, which had neither.

@ekzhu
Copy link
Collaborator

ekzhu commented Feb 12, 2025

@mwarqee yes, we do have a note on AssistantAgent that for o1-preview and o1-mini we don't support system message.

https://microsoft.github.io/autogen/stable/reference/python/autogen_agentchat.agents.html#module-autogen_agentchat.agents

So in this case just don't use system message.

@mwarqee
Copy link

mwarqee commented Feb 13, 2025

@ekzhu - sorry if this question might have an obvious answer (i did not found it in the docs for class AssistantAgent), but what are options are available to pass instructions to the different AssistantAgent(s) ? Should we pass them as tasks?

@ekzhu
Copy link
Collaborator

ekzhu commented Feb 13, 2025

Yes, for o1-mini and o1-preview -- they just take the task. I believe this prompting guide is useful when it comes to prompting these types of models. https://techcommunity.microsoft.com/blog/azure-ai-services-blog/prompt-engineering-for-openai%E2%80%99s-o1-and-o3-mini-reasoning-models/4374010

@ekzhu
Copy link
Collaborator

ekzhu commented Feb 22, 2025

For this issue. Let's focus on adding some explanation in the SelectorGroupChat guide about how to use it with reasoning model like o3-mini -- it comes down to the prompting strategy for agents, and avoid using the planning agent pattern, just rely on the team's selector itself.

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

Successfully merging a pull request may close this issue.

5 participants