Skip to content

fix: filter empty assistant messages for all providers#1

Merged
spencer-hong merged 1 commit intodevfrom
fix/filter-empty-assistant-messages
Mar 31, 2026
Merged

fix: filter empty assistant messages for all providers#1
spencer-hong merged 1 commit intodevfrom
fix/filter-empty-assistant-messages

Conversation

@spencer-hong
Copy link
Copy Markdown
Collaborator

Summary

  • Remove the @ai-sdk/anthropic || @ai-sdk/amazon-bedrock guard from the empty message filter in normalizeMessages so it runs unconditionally for all providers
  • Many providers (Moonshot/Kimi, OpenAI-compatible, etc.) reject empty assistant messages with "the message at position X with role 'assistant' must not be empty"
  • This commonly happens when a tool call is cancelled or when the assistant response is tool-only with no text content during session resumption

Context

Test plan

  • Verify resumed opencode sessions with Kimi don't error on empty assistant messages
  • Verify Anthropic/Bedrock behavior unchanged (was already filtered, now unconditional)
  • Rebuild E2B template and test

🤖 Generated with Claude Code

Remove the @ai-sdk/anthropic || @ai-sdk/amazon-bedrock guard from the
empty message filter in normalizeMessages so it runs unconditionally.

Many providers (Moonshot/Kimi, OpenAI-compatible, etc.) reject empty
assistant messages with "the message at position X with role 'assistant'
must not be empty". This commonly happens when a tool call is cancelled
or when the assistant response is tool-only with no text content.

Refs: anomalyco#6056

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

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.

@github-actions
Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown

The following comment was made by an LLM, it may be inaccurate:

@spencer-hong spencer-hong merged commit e4d8750 into dev Mar 31, 2026
6 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant