fix(provider): handle empty content for bedrock/openai-compatible APIs#17396
fix(provider): handle empty content for bedrock/openai-compatible APIs#17396JackFGreen wants to merge 1 commit into
Conversation
- Transform empty assistant content ("") to null in openai-compatible requests
- Extend empty content filtering to openai-compatible provider
- Filter empty text blocks from tool-result content arrays
- Handle tool outputs with empty text but attachments
- Add placeholder text when tool output is completely empty
- Add comprehensive test coverage for edge cases
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one related PR that may be relevant: Potential Duplicate:
The other results returned were either the current PR itself (#17396) or unrelated PRs about different providers and features. |
|
same issue,waiting! |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #16332
Type of change
What does this PR do?
AWS Bedrock rejects requests with empty text content blocks. This occurred when using custom providers with @ai-sdk/openai-compatible, especially during tool calls that return empty text (e.g., Figma MCP downloading images).
The fix adds filtering for empty content blocks at multiple levels:
This prevents the "ValidationException: messages: text content blocks must be non-empty" error from Bedrock.
How did you verify your code works?
Screenshots / recordings
Not applicable - this is a backend bug fix without UI changes.
Checklist