fix(anthropic): send placeholder for empty assistant turns instead of dropping - #421
Open
cpsievert wants to merge 2 commits into
Open
fix(anthropic): send placeholder for empty assistant turns instead of dropping#421cpsievert wants to merge 2 commits into
cpsievert wants to merge 2 commits into
Conversation
… dropping Dropping an empty assistant turn could produce two consecutive user messages, violating the API's user/assistant alternation requirement. Send an '[empty string]' placeholder instead, matching ellmer's fix (tidyverse/ellmer#1099) and chatlas's existing empty-text normalization. Closes #416
cpsievert
force-pushed
the
fix-anthropic-empty-assistant-turn
branch
from
September 4, 2026 00:52
c3c1ac7 to
068df80
Compare
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.
Closes #416.
AnthropicProvider._as_message_paramsdropped assistant turns with zero content blocks, which could produce two consecutiveusermessages and violate Anthropic's user/assistant alternation requirement. Now sends an[empty string]placeholder instead, matching ellmer's fix (tidyverse/ellmer#1099, tidyverse/ellmer#1100) and chatlas's existing empty-text normalization in_content.py.Also audited other providers for a similar drop-empty-turn pattern — none exists; the fix is Anthropic-only. The outdated test asserting the dropping behavior was replaced with one asserting the placeholder.