From 8c7475aafee57124b419422ae935bac0c49bafab Mon Sep 17 00:00:00 2001 From: "rosetta-livekit-bot[bot]" <282703043+rosetta-livekit-bot[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2026 12:57:25 +0000 Subject: [PATCH] fix(anthropic): add non-whitespace trailing dummy --- plugins/anthropic/src/llm.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/anthropic/src/llm.ts b/plugins/anthropic/src/llm.ts index 4f963d462..33fdf6c57 100644 --- a/plugins/anthropic/src/llm.ts +++ b/plugins/anthropic/src/llm.ts @@ -101,6 +101,8 @@ export class LLM extends llm.LLM { * strict alternating-turn requirement. * - A dummy `(empty)` user message is injected if the conversation doesn't * start with a user turn. + * - A dummy user message is appended if the conversation ends with an + * assistant turn, since Claude 4.6+ does not support prefilling. */ protected _buildAnthropicContext(chatCtx: llm.ChatContext): { system: Anthropic.TextBlockParam[]; @@ -172,6 +174,11 @@ export class LLM extends llm.LLM { messages.unshift({ role: 'user', content: '(empty)' }); } + // Claude 4.6+ does not support prefilling (trailing assistant messages). + if (messages.length > 0 && messages[messages.length - 1]!.role === 'assistant') { + messages.push({ role: 'user', content: [{ type: 'text', text: '.' }] }); + } + return { system, messages }; }