-
Notifications
You must be signed in to change notification settings - Fork 192
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
[Bug]: Deep Seek R1 errors in group chat setup #590
Labels
bug
Something isn't working
Comments
It seems that the deepseek reasoner model has specific requirements for multi-turn conversations as shown here: https://api-docs.deepseek.com/guides/reasoning_model A temporary workaround i came up with uses a custom Reasoner class, and a different model for ChatManager (can be deepseek-chat or any other model). Here's the code that works: import autogen
from autogen.coding import LocalCommandLineCodeExecutor
from model_list import (config_list_deepseek_chat,
config_list_deepseek_reasoner,
config_list_openai_4o_mini)
class DeepSeekReasonerAssistant(autogen.AssistantAgent):
def __init__(self, name, **kwargs):
super().__init__(name, **kwargs)
def generate_reply(self, messages=None, sender=None, config=None):
print(f"\n=== {self.name} Processing Messages ===")
# Get messages from chat history if available
if hasattr(self, "chat_messages") and sender in self.chat_messages:
chat_history = self.chat_messages[sender]
else:
chat_history = messages if messages else []
if chat_history:
# Create new message sequence
new_messages = []
# Add system message if it exists
if hasattr(self, "system_message"):
new_messages.append({"role": "system", "content": self.system_message})
# Add original messages ensuring alternation
for msg in chat_history:
if len(new_messages) == 0 or msg["role"] != new_messages[-1]["role"]:
new_messages.append(msg)
# Check if last message was from assistant
if new_messages and new_messages[-1]["role"] == "assistant":
new_messages.append({"role": "user", "content": "continue"})
return super().generate_reply(
messages=new_messages, sender=sender, config=config
)
return super().generate_reply(messages=messages, sender=sender, config=config)
# Create agents using the custom class
assistant = DeepSeekReasonerAssistant(
"assistant",
system_message="You are a coding assistant. Write code for the given task.",
llm_config={
"config_list": config_list_deepseek_reasoner,
},
)
supervisor = DeepSeekReasonerAssistant(
"supervisor",
system_message="""You are a code reviewer. Review code for:
1. Correctness
2. Error handling
3. Performance
4. Best practices""",
llm_config={
"config_list": config_list_deepseek_reasoner,
},
)
user_proxy = autogen.UserProxyAgent(
"user_proxy",
human_input_mode="NEVER",
code_execution_config={
"executor": LocalCommandLineCodeExecutor(work_dir="coding"),
},
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0,
)
# Create group chat
groupchat = autogen.GroupChat(
agents=[user_proxy, assistant, supervisor], messages=[], max_round=5
)
# Manager with chat model
manager = autogen.GroupChatManager(
groupchat=groupchat,
system_message="""You are the coordinator. Follow this sequence:
1. When user asks a question, select assistant to write code
2. After assistant provides code, select supervisor to review it
3. If the problem has been resolved respond with TERMINATE""",
llm_config={
"config_list": config_list_deepseek_chat,
},
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0,
)
print("Starting chat...")
user_proxy.initiate_chat(
manager, message="Create a chart showing NVDA and TESLA stock prices."
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
facing errors when using deepseek-reasoner model in group chat.
Error for other model (gpt4o-mini in demo) as group manager, deepseek-reasoner for both group members
{'error': {'message': 'deepseek-reasoner does not support successive user or assistant messages (messages[2] and messages[3] in your input). You should interleave the user/assistant messages in the message sequence.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}
Error for deepseek-reasoner used as groupchat manager, others remain the same as (1)
Error code: 400 - {'error': {'message': 'The last message of deepseek-reasoner must be a user message, or an assistant message with prefix mode on (refer to https://api-docs.deepseek.com/guides/chat_prefix_completion).', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}
Steps to reproduce
I have created a repo to reproduce the errors.
Model Used
deepseek-reasoner
Expected Behavior
2 errors mentioned
Screenshots and logs
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: