You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
In one session developing for awhile with DeepSeek-V4-Flash, received "all messages must have non-empty content" errors #31971
I was in the midst of a coding session with DeepSeek-V4-Flash/Max, and reportedly had used ~354k tokens / 34% of its context window, when ~suddenly my prompts have been receiving a repeated error (tried several reprompts, with same error):
Bad Request: {"error":{"message":"messages.625: all messages must have non-empty content","type":"invalid_request_error","param": ┃ null,"code":"invalid_request_error"}}
I was using OpenCode 1.15 at the time, and when I started receiving the error, I upgraded to the current latest, but still the error is being given in that session. Newly created sessions are initially interacting w/o such error(s)...
I had reported a somewhat similar blockage with a 'reasoning_content' error in a previous version of opencode in #24870 but this appears to be a totally different error message. If they're actually the same issue, then IMO the code should be providing the same error.
Confirming this bug with additional reproduction data
I can confirm this exact issue from an independent reproduction. Sharing detailed forensic analysis below.
Reproduction Environment
Opencode version: v1.17.9 (runtime), CLI v0.3.28
Provider: DeepSeek API (not limited to V4-Flash — also reproduces on other DeepSeek models)
Platform: Multica agent platform using Opencode as the LLM runtime
Root Cause Analysis
The DeepSeek adapter constructs a messages array from the conversation context. When the context grows large (50+ messages in a multi-turn coding session with long comments/threads), at least one message in the array ends up with empty content (content: ""). DeepSeek API rejects this with:
invalid_request_error: all messages must have non-empty content
This is NOT intermittent — once the context grows past a threshold where empty-content messages appear, every subsequent API call in the same session fails, effectively bricking the session.
Exact Trigger in Our Case
A coding agent working on a complex issue submitted a ~7,800-character research report as a comment
The main agent (using Opencode + DeepSeek as runtime) attempted to process this comment
Within 8 seconds of the long comment being posted, the API returned messages.55: all messages must have non-empty content
Subsequent retries hit the same error at different indices (messages.47, messages.625 — the index varies by context size)
New sessions work fine initially, consistent with your observation
Clinical Timeline (2026-06-24 UTC)
Time
Event
10:17:12
Agent posts a 7,822-character research report comment
10:17:20
DeepSeek API returns messages.55: all messages must have non-empty content
10:39:23
Retry attempt — same error at messages.47
10:41:00
Another retry — same error at messages.47
Suspected Code Path
The issue likely originates in the message normalization/transformation pipeline before the API call is dispatched. Empty content messages can arise from:
Normalization dropping content: Functions like normalizeMessages() may strip text parts from messages that have reasoning blocks but no text content, leaving a message with content: ""
Thinking mode artifacts: DeepSeek's thinking mode can produce assistant messages where reasoning_content exists but text content is empty. If the round-trip normalization preserves reasoning but drops the empty text part, and the API still requires non-empty content, this triggers the error
Context compaction: Long sessions trigger compaction, which may produce messages with empty content fields in edge cases
Recommended Fix
Add a filtering step in the DeepSeek adapter/provider path that removes messages with empty/null content from the messages array before dispatching to the API. This is a defensive safety net — regardless of which upstream code path produces the empty message, the adapter should never send it to DeepSeek.
In pseudocode:
// Before sending to DeepSeek APImessages=messages.filter(m=>{if(typeofm.content==='string')returnm.content.length>0;if(Array.isArray(m.content))returnm.content.length>0;returnfalse;});
This is a ~3-line change with zero API surface impact. It addresses the symptom regardless of which specific upstream path (normalization, compaction, thinking mode round-trip, etc.) produced the empty message.
These are all reasoning-content-specific fixes. A generic empty-content filter at the API dispatch boundary would catch all sources of this class of error, including non-reasoning cases.
Workaround for Users
Until this is fixed upstream, users can work around by starting a fresh session when the error occurs — the error is session-state-dependent, and new sessions start with clean context.
This analysis was performed on the Multica platform (multica-ai/multica). The Opencode runtime is used as the LLM execution backend for coding agents.
Activity
github-actions commentedon Jun 12, 2026
This issue might be a duplicate of existing issues. Please check:
DXXS commentedon Jun 12, 2026
I had reported a somewhat similar blockage with a 'reasoning_content' error in a previous version of opencode in #24870 but this appears to be a totally different error message. If they're actually the same issue, then IMO the code should be providing the same error.
Oxygen56 commentedon Jun 24, 2026
Confirming this bug with additional reproduction data
I can confirm this exact issue from an independent reproduction. Sharing detailed forensic analysis below.
Reproduction Environment
Root Cause Analysis
The DeepSeek adapter constructs a
messagesarray from the conversation context. When the context grows large (50+ messages in a multi-turn coding session with long comments/threads), at least one message in the array ends up with empty content (content: ""). DeepSeek API rejects this with:This is NOT intermittent — once the context grows past a threshold where empty-content messages appear, every subsequent API call in the same session fails, effectively bricking the session.
Exact Trigger in Our Case
messages.55: all messages must have non-empty contentmessages.47,messages.625— the index varies by context size)Clinical Timeline (2026-06-24 UTC)
messages.55: all messages must have non-empty contentmessages.47messages.47Suspected Code Path
The issue likely originates in the message normalization/transformation pipeline before the API call is dispatched. Empty content messages can arise from:
normalizeMessages()may strip text parts from messages that have reasoning blocks but no text content, leaving a message withcontent: ""reasoning_contentexists but textcontentis empty. If the round-trip normalization preserves reasoning but drops the empty text part, and the API still requires non-emptycontent, this triggers the errorRecommended Fix
Add a filtering step in the DeepSeek adapter/provider path that removes messages with empty/null content from the
messagesarray before dispatching to the API. This is a defensive safety net — regardless of which upstream code path produces the empty message, the adapter should never send it to DeepSeek.In pseudocode:
This is a ~3-line change with zero API surface impact. It addresses the symptom regardless of which specific upstream path (normalization, compaction, thinking mode round-trip, etc.) produced the empty message.
Related Fixes That Don't Fully Cover This
These are all reasoning-content-specific fixes. A generic empty-content filter at the API dispatch boundary would catch all sources of this class of error, including non-reasoning cases.
Workaround for Users
Until this is fixed upstream, users can work around by starting a fresh session when the error occurs — the error is session-state-dependent, and new sessions start with clean context.
This analysis was performed on the Multica platform (multica-ai/multica). The Opencode runtime is used as the LLM execution backend for coding agents.
github-actions commentedon Aug 24, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.