Skip to content

fix: add final empty-content guard in message() pipeline#33706

Open
Oxygen56 wants to merge 2 commits into
anomalyco:devfrom
Oxygen56:fix/empty-content-guard
Open

fix: add final empty-content guard in message() pipeline#33706
Oxygen56 wants to merge 2 commits into
anomalyco:devfrom
Oxygen56:fix/empty-content-guard

Conversation

@Oxygen56

@Oxygen56 Oxygen56 commented Jun 24, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #23260
Closes #26320

Type of change

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

What does this PR do?

Adds a provider-agnostic empty-content guard at the end of the message() function in packages/opencode/src/provider/transform.ts. The guard filters out messages with empty content (empty string, empty array, or all-empty text/reasoning parts) before they reach any provider API.

Previously only Anthropic and Bedrock had provider-specific guards; every other provider — including DeepSeek — could receive messages with empty content and fail with hard errors that permanently break the active session (e.g. DeepSeek returns 400 Bad Request: messages.N: all messages must have non-empty content).

The fix is a single O(n) filter (~15 lines) placed at the end of message(), provider-agnostic by design, catching all current and future empty-content sources (unsupportedParts, normalizeMessages, interleaved reasoning filter, etc.).

How did you verify your code works?

Screenshots / recordings

N/A (not a UI change)

Checklist

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

Re-creation of #33647 which was closed by bot timer

Oxygen56 added 2 commits June 24, 2026 19:13
Adds a provider-agnostic safety net at the end of the message()
function that filters out messages with empty string content or
empty array content before they reach any provider API.

Previously only Anthropic and Bedrock had local guards; providers
like DeepSeek would receive messages with empty content and fail
with "messages.N: all messages must have non-empty content".

Fixes anomalyco#23260
Covers empty string content, empty array content, all-empty text
parts, mixed valid/invalid messages, and provider-agnostic behavior.

Ref anomalyco#23260
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

1 participant