Skip to content

fix(providers): strip empty text blocks from API requests - #394

Merged
prvnsmpth merged 2 commits into
masterfrom
fix/validate-text-blocks-non-empty
Jul 30, 2026
Merged

fix(providers): strip empty text blocks from API requests#394
prvnsmpth merged 2 commits into
masterfrom
fix/validate-text-blocks-non-empty

Conversation

@prvnsmpth

Copy link
Copy Markdown
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
@prvnsmpth
prvnsmpth merged commit 9e19be1 into master Jul 30, 2026
35 checks passed
@prvnsmpth
prvnsmpth deleted the fix/validate-text-blocks-non-empty branch July 30, 2026 10:02
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.

1 participant