Repository navigation
End a requested reply with the user when a system item follows the assistant - #280
Merged
Merged
Conversation
…sistant #277 added a short user turn when a requested reply's conversation ends with the assistant, since Claude 5.x refuses assistant prefill. It looked only at the very last message, so a system item the host added after the assistant's line hid the assistant from the check and the conversation went out without the user turn. The check now looks at the last message that is not a system message. Test: SendAsync_ResponseRequestAfterTheAssistantsLineAndASystemItem_EndsTheConversationWithTheUser.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #277 (fixes #275).
#277 ends a requested reply's conversation (
response.create) with a short user turn when it ends with theassistant, because Claude 5.x refuses assistant prefill. Its check looked only at the very last message. A system item
the host adds after the assistant's line hid the assistant from that check, so the conversation went out without the
user turn.
Changes
CascadedRealtimeSession.ConversationFor: the user turn is added when the last message that is not a systemmessage is the assistant's.
[user, system]: the existing grounded test still pins that no turn is added;core/realtime-voice.mdand End a requested cascaded reply's conversation with the user, not the assistant #277's changelog entry, which is not released yet.Why a system item can follow the assistant's line
The Anthropic
IChatClient(Anthropic 12.55.0) hoists only leading system messages intosystem. A system messageafter the first non-system message stays in
messageswith rolesystem. So[…, assistant, system]still ends afterthe assistant, and is not a user turn.
DefaultRealtimeConversationadds system items only after a user utterancetoday, so this is a hardening for hosts that send their own items, not a fix for a reported failure.
Tests
SendAsync_ResponseRequestAfterTheAssistantsLineAndASystemItem_EndsTheConversationWithTheUser. It fails withEnd a requested cascaded reply's conversation with the user, not the assistant #277's check ("last message is the assistant's") and passes with this one.
🤖 Generated with Claude Code