You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the 400 server error about alternating user-assistant roles in messages, we need to handle this outside of model client, i.e., in `AssistantAgent` and `SelectorGroupChat`, where the model clients are used. Based on the model family in `model_info` field, we should inject an empty user message when there are consecutive assistant messages.
openai.BadRequestError: Error code: 400 - {'error': {'message': 'deepseek-reasoner does not support successive user or assistant messages (messages[1] and messages[2] in your input). You should interleave the user/assistant messages in the message sequence.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}
Steps:
Investigate what are the model families that require this strict alternating user-assistant roles? (DeepSeek R1, Mistral AI)
In AssistantAgent and SelectorGroupChat, where model client is used, ensure the messages are following the strict order when the above model families are involved. We can do this by concatenation of messages with repeated roles, or injecting empty message -- need to test them.
The text was updated successfully, but these errors were encountered:
ekzhu
changed the title
Injecting empty user/assistant message when the model API requires strict alternating user-assistant roles
Support model APIs that requires strict alternating user-assistant roles
Mar 16, 2025
ekzhu
changed the title
Support model APIs that requires strict alternating user-assistant roles
Support model APIs that require strict alternating user-assistant roles
Mar 16, 2025
Originally posted by @ekzhu in #5961 (comment)
Reference of 400 error:
Steps:
AssistantAgent
andSelectorGroupChat
, where model client is used, ensure the messages are following the strict order when the above model families are involved. We can do this by concatenation of messages with repeated roles, or injecting empty message -- need to test them.The text was updated successfully, but these errors were encountered: