[PR #4811] fix: filter empty messages in toModelMessage #11127

Closed
opened 2026-02-16 18:15:55 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4811

State: closed
Merged: Yes


Summary

  • Filter out messages with empty parts arrays before sending to provider API

Problem

Related to #2655

Messages with only ignored: true text parts pass the initial parts.length === 0 check but end up with empty content after filtering, causing provider API errors:

messages.X: all messages must have non-empty content except for the optional final assistant message

Solution

Filter messages with empty parts after processing, before convertToModelMessages().

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4811 **State:** closed **Merged:** Yes --- ## Summary - Filter out messages with empty parts arrays before sending to provider API ## Problem Related to #2655 Messages with only `ignored: true` text parts pass the initial `parts.length === 0` check but end up with empty content after filtering, causing provider API errors: ``` messages.X: all messages must have non-empty content except for the optional final assistant message ``` ## Solution Filter messages with empty parts after processing, before `convertToModelMessages()`.
yindo added the pull-request label 2026-02-16 18:15:55 -05:00
yindo closed this issue 2026-02-16 18:15:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11127