[PR #594] [CLOSED] Fix: Filter empty messages to prevent conversation breaks #9657

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

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/594
Author: @jhrudden
Created: 7/1/2025
Status: Closed

Base: devHead: fix/filter-step-start-only-messages


📝 Commits (1)

  • 4c30fcc fix(session): filter messages with only step-start parts to prevent API errors

📊 Changes

1 file changed (+30 additions, -3 deletions)

View changed files

📝 packages/opencode/src/session/index.ts (+30 -3)

📄 Description

Problem

Noticed that a conversation broke because I had an LLM API error occur in a conversation. This happened suddenly and broke the whole conversation from then on. Broken Convo (share link doesn't show all context)

Screenshot 2025-07-01 at 8 11 31 PM

Issue was streamText can produce assistant responses that contain only step-start parts. When these messages are converted to core messages via convertToCoreMessages, they result in empty content arrays (content: []) which trigger API errors from LLM providers.

Root Cause

step-start parts are UI metadata that get filtered out during core message conversion. If an assistant message only contains step-start parts (no text, tool calls, etc.), the converted core message becomes invalid with empty content, causing API failures.

Added hasValidContent filter that prevents messages with only step-start parts from reaching convertToCoreMessages, avoiding API errors from empty content messages while preserving valid messages.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/594 **Author:** [@jhrudden](https://github.com/jhrudden) **Created:** 7/1/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/filter-step-start-only-messages` --- ### 📝 Commits (1) - [`4c30fcc`](https://github.com/anomalyco/opencode/commit/4c30fcc2e66001b32664f83d69e0d7920a772a8b) fix(session): filter messages with only step-start parts to prevent API errors ### 📊 Changes **1 file changed** (+30 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/session/index.ts` (+30 -3) </details> ### 📄 Description ### Problem Noticed that a conversation broke because I had an LLM API error occur in a conversation. This happened suddenly and broke the whole conversation from then on. [Broken Convo](https://opencode.ai/s/152Zoncg) (share link doesn't show all context) <img width="854" alt="Screenshot 2025-07-01 at 8 11 31 PM" src="https://github.com/user-attachments/assets/18f20497-adeb-4e7b-bc44-1bda6997255c" /> Issue was `streamText` can produce assistant responses that contain only `step-start` parts. When these messages are converted to core messages via `convertToCoreMessages`, they result in empty content arrays (`content: []`) which trigger API errors from LLM providers. ### Root Cause `step-start` parts are UI metadata that get filtered out during core message conversion. If an assistant message only contains `step-start` parts (no text, tool calls, etc.), the converted core message becomes invalid with empty content, causing API failures. Added `hasValidContent` filter that prevents messages with only `step-start` parts from reaching `convertToCoreMessages`, avoiding API errors from empty content messages while preserving valid messages. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:13:56 -05:00
yindo closed this issue 2026-02-16 18:13:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9657