Duo Chat error causes subsequent chat to fail due to consecutive Assistant messages
Summary
Currently if a type of chat error is triggered, any subsequent error will fail. Claude error message would say
roles must alternate between "user" and "assistant", but found multiple "assistant" roles in a row
Inspecting the llm.log, we see that the order of the messages are altered somehow.
Steps to reproduce
For example, when I chat using "hihi" followed by "hoho":
The llm.log will have these instead:
"content": [
{
"role": "user",
"content": "hihi"
},
{
"role": "assistant",
"content": "Hello! I'm GitLab Duo Chat, an AI assistant created by GitLab. How can I assist you today? Please provide more details about what you need help with related to GitLab or software development."
},
{
"role": "assistant",
"content": "Hello! I did not quite understand your request. Could you please provide more details about what you need help with related to GitLab or software development? I'll do my best to assist you."
},
{
"role": "system",
"content": "You are ..."
},
{
"role": "user",
"content": "hoho"
},
{
"role": "assistant",
"content": "\nThought:"
}
],
Example Project
n/a
What is the current bug behavior?
the subsequent chat does not work.
What is the expected correct behavior?
the subsequent chat should still work.
Relevant logs and/or screenshots
(see example above)
Output of checks
Results of GitLab environment info
Results of GitLab application Check
Possible fixes
As a temporary solution, we can filter out consecutive assistant messages.
As a long term solution, we need to investigate why the order of the messages are messed up.