fix(providers): strip empty text blocks from API requests - #394
Merged
Conversation
prvnsmpth
commented
Jul 30, 2026
Contributor
- Anthropic and Bedrock providers now strip empty/whitespace-only text blocks from message content and tool results via the shared message adapter
- OpenAI provider skips empty text blocks when building response input items
- OpenAI-compatible provider skips empty text blocks inside tool result content (top-level was already guarded)
- Gemini, Vertex AI, and Azure Foundry were already handling this correctly or delegate to the fixed providers
- The fix prevents the Anthropic API's "text blocks must be non-empty" validation error that could occur when persisted conversation history accumulates empty text blocks through interrupted streams or empty tool results
- anthropic_message_adapter: filter empty/whitespace-only text blocks from content lists and tool_result content (fixes Anthropic + Bedrock) - openai: skip empty text blocks when building response input items - openai_compatible: skip empty text blocks in tool result content - Gemini already handled this; Vertex/Azure Foundry delegate to providers above so they're covered
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.