Skip to content

End a requested reply with the user when a system item follows the assistant - #280

Merged
MikeAlhayek merged 1 commit into
mainfrom
ma/cascade-requested-reply-after-system-item
Oct 19, 2026
Merged

MikeAlhayek merged 1 commit into
mainfrom
ma/cascade-requested-reply-after-system-item

Conversation

@MikeAlhayek

Copy link
Copy Markdown
Member

Follow-up to #277 (fixes #275).

#277 ends a requested reply's conversation (response.create) with a short user turn when it ends with the
assistant, 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 system
    message is the assistant's.
  • Unchanged:
    • a grounded turn, [user, system]: the existing grounded test still pins that no turn is added;
    • a requested reply with no history (the opening line);
    • every reply to the user.
  • Docs: core/realtime-voice.md and 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 into system. A system message
after the first non-system message stays in messages with role system. So […, assistant, system] still ends after
the assistant, and is not a user turn. DefaultRealtimeConversation adds system items only after a user utterance
today, so this is a hardening for hosts that send their own items, not a fix for a reported failure.

Tests

🤖 Generated with Claude Code

…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.
@MikeAlhayek
MikeAlhayek merged commit d1d509e into main Oct 19, 2026
10 checks passed
@MikeAlhayek
MikeAlhayek deleted the ma/cascade-requested-reply-after-system-item branch October 19, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A cascade's requested reply fails on models without assistant prefill (Claude 5.x)

1 participant