GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(provider): handle empty content for bedrock/openai-compatible APIs by JackFGreen · Pull Request #17396 · anomalyco/opencode

Conversation

@JackFGreen

@JackFGreen JackFGreen commented Mar 13, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #16332

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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:

  • Transforms empty assistant content ("") to null for openai-compatible providers
  • Filters out empty text blocks from tool-result content arrays
  • Handles edge cases where tool outputs have attachments but no text
  • Adds placeholder text when tool output is completely empty

This prevents the "ValidationException: messages: text content blocks must be non-empty" error from Bedrock.

How did you verify your code works?

  • Tested with custom provider using @ai-sdk/openai-compatible pointing to AWS Bedrock
  • Verified tool calls with empty text outputs work correctly
  • Verified tool calls with attachments but no text are handled properly
  • Added comprehensive test coverage (500+ lines across 3 test files)
  • All existing tests pass

Screenshots / recordings

Not applicable - this is a backend bug fix without UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fermumen reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@JackFGreen
fix(provider): handle empty content for bedrock/openai-compatible APIs
51dd029
- 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
@github-actions

github-actions Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

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:

  • fix(provider): skip empty-text filtering for assistant messages in normalizeMessages (fix(provider): skip empty-text filtering for assistant messages in normalizeMessages (#16748) #16750)

    • fix(provider): skip empty-text filtering for assistant messages in normalizeMessages (#16748) #16750

    This PR appears to be directly related as it also deals with empty text filtering for provider messages. It specifically addresses skipping empty-text filtering for assistant messages in normalizeMessages, which relates to the same issue area as PR fix(provider): handle empty content for bedrock/openai-compatible APIs #17396's handling of empty content blocks.

The other results returned were either the current PR itself (#17396) or unrelated PRs about different providers and features.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Mar 15, 2026
fix: filter empty message content for all providers to prevent LiteLLM proxy sanitization artifact #17565
Closed
fix(provider): drop empty content messages after interleaved reasoning filter #17712
Closed
fix(opencode): filter empty text content blocks for all providers #17742
Closed
@JackFGreen JackFGreen mentioned this pull request Mar 23, 2026
bug: text content blocks must be non-empty in custom provider #16332
Closed
This was referenced Apr 2, 2026
fix(opencode): improve local OpenAI-compatible backend robustness #20668
Closed
fix(provider): filter empty text blocks for base_url providers #21190
Closed
@rushant001

rushant001 commented Apr 13, 2026

Copy link
Copy Markdown

same issue,waiting!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@opencode-agent
opencode-agent Bot force-pushed the dev branch from 2f2ed11 to 9f201d6 Compare April 16, 2026 21:55
This was referenced Apr 18, 2026
fix(provider): add universal empty-content guard to message pipeline #23259
Closed
bug: message pipeline has no final empty-content guard, causing ValidationException on Bedrock and hard failures on other providers #23260
Closed
@rekram1-node

rekram1-node commented May 15, 2026

Copy link
Copy Markdown
Member

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:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node rekram1-node closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

bug: text content blocks must be non-empty in custom provider

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@JackFGreen @rushant001 @rekram1-node
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.