-
Notifications
You must be signed in to change notification settings - Fork 311
fix(anthropic): add non-whitespace trailing dummy #1891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fix/anthropic-retry-fresh-stream
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: '.' }] }); | ||
| } | ||
|
Comment on lines
+177
to
+180
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 New trailing-message fix breaks existing unit test for message merging A dummy user message is unconditionally appended when the last message is from the assistant ( Impact: The test suite will fail, blocking CI and preventing the PR from merging. Test failure trace for "merges consecutive same-role messages"The test at The test file was not modified by this PR, so this is an oversight. The test needs updating to expect the new trailing user message. Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| return { system, messages }; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚩 Dummy message content '.' differs from existing placeholder style and may influence model output
The new trailing dummy message uses
{ type: 'text', text: '.' }atplugins/anthropic/src/llm.ts:179, while the existing leading dummy message uses the string'(empty)'atplugins/anthropic/src/llm.ts:174. Beyond the stylistic inconsistency, a single period could be interpreted by Claude as actual user input (e.g., prompting a "How can I help you?" response), whereas'(empty)'more clearly signals a placeholder. This is a design choice rather than a correctness bug, but it may affect response quality in conversations where the assistant's last message needs a follow-up.Was this helpful? React with 👍 or 👎 to provide feedback.