Do not allow repeated roles on Duo Chat to prevent errors
requested to merge 469101-duo-chat-error-causes-subsequent-chat-to-fail-due-to-consecutive-assistant-messages into master
What does this MR do and why?
We noticed that sometimes Duo Chat can get into an error state where it has multiple of the same role in a row.
Then we get this error from the AI Gateway:
roles must alternate between "user" and "assistant", but found multiple "assistant" roles in a row
This MR makes it so that only the last message in a row with a role gets added to the prompt.
MR acceptance checklist
Screenshots or screen recordings
N/A
How to set up and validate locally
- Regression test Duo Chat
- You can edit the code here to add another 'Utils::Prompt.as_assistant' method call. It should not work on master, but it does with this change.
Related to #469101 (closed)
Edited by Lesley Razzaghian