-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Python: Agents - Chat throwing "A conversation must alternate between user and assistant roles. Make sure the conversation alternates between user and assistant roles and try again." #10281
Comments
Although AWS didn't provide the details on their docs, I was able to find this on Anthropic's API doc: https://docs.anthropic.com/en/api/messages#body-messages Looks like the Anthropic models do require alternating user and assistant messages. Could you please try another model that is available on AWS Bedrock? |
I have a similar problem when running smaller models locally with C#; when the last message isn't from a user the model refuses to answer and the response content is empty. Example Requests and responses in an agent setting:
response:
|
This is a limitation of the Bedrock service. Please make sure your chat history alternates between user and assistant messages and the last message must be a user message, when using the Bedrock service. |
Discussed in #10271
Originally posted by yarns123 January 23, 2025
Hi,
im trying to use this example https://github.com/microsoft/semantic-kernel/blob/main/python/samples/getting_started_with_agents/step3_chat.py with AWS Bedrock Claude Sonnet 3.5. Unfortunately I get this error:
botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the Converse operation: A conversation must alternate between user and assistant roles. Make sure the conversation alternates between user and assistant roles and try again.
It seems that ChatHistory for this model cannot have two consecutive responses from the assistant. I would be grateful for any ideas on how to solve this problem
The text was updated successfully, but these errors were encountered: