[PR #6383] fix: filter messages with only step-start parts in toModelMessage #11872

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

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

State: closed
Merged: Yes


Summary

Fixes compaction errors caused by messages containing only step-start parts being sent to the Claude API, which rejects them with "all messages must have non-empty content".

Problem

The previous fix (#4811, commit 13f89fdb8) filtered messages with zero parts, but messages containing only step-start parts still passed through. Since step-start is metadata that doesn't produce actual API content, these messages resulted in empty content blocks.

Solution

Changed the filter from checking msg.parts.length > 0 to checking msg.parts.some((part) => part.type !== "step-start"), ensuring messages have at least one content-producing part (text, tool results, reasoning, etc.) rather than just metadata parts.

Testing

This fix ensures that during compaction, only messages with meaningful content are sent to the API, preventing the "non-empty content" validation error.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6383 **State:** closed **Merged:** Yes --- ## Summary Fixes compaction errors caused by messages containing only `step-start` parts being sent to the Claude API, which rejects them with "all messages must have non-empty content". ## Problem The previous fix (#4811, commit 13f89fdb8) filtered messages with zero parts, but messages containing **only** `step-start` parts still passed through. Since `step-start` is metadata that doesn't produce actual API content, these messages resulted in empty content blocks. ## Solution Changed the filter from checking `msg.parts.length > 0` to checking `msg.parts.some((part) => part.type !== "step-start")`, ensuring messages have at least one content-producing part (text, tool results, reasoning, etc.) rather than just metadata parts. ## Testing This fix ensures that during compaction, only messages with meaningful content are sent to the API, preventing the "non-empty content" validation error.
yindo added the pull-request label 2026-02-16 18:16:48 -05:00
yindo closed this issue 2026-02-16 18:16:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11872