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
Missing reasoning_content field in the assistant message for DeepSeek API implementation #17523
When using DeepSeek models with thinking mode enabled (either via reasoner model IDs or thinking option), assistant messages after the last user message were not receiving an (empty) reasoning_content field. This caused issues with the DeepSeek API's thinking mode behavior, where every assistant message in thinking mode must provide a reasoning_content field, even if empty.
Steps to Reproduce
Use a DeepSeek model with thinking mode enabled (e.g., deepseek-reasoner model, or any DeepSeek model with thinking: { type: "enabled" } option)
Send a conversation with multiple turns (user -> assistant -> user -> assistant)
Observe that assistant messages after the last user message do not have reasoning_content set, when previously empty.
The DeepSeek API returns error 400 in this scenario
Expected Behavior
ALL assistant messages after the last user message should have an empty reasoning_content field when thinking mode is enabled for DeepSeek models, to comply with API expectations.
Actual Behavior
Only assistant messages with non-empty reasoning content received the reasoning_content field. Assistant messages with empty reasoning content after the last user message did not have the field set.
Root Cause
The ProviderTransform.message function in packages/opencode/src/provider/transform.ts only added reasoning_content when there was actual reasoning text present, but deepseek requires also empty "" reasoning_content fields.
Solution
Modified the logic to:
Detect when thinking mode is enabled for DeepSeek models (via model capabilities, model ID, or thinking option)
Find the index of the last user message in the conversation
For all assistant messages after that index, set an empty reasoning_content field
Maintain backward compatibility for non-thinking mode usage
Affected Models
All DeepSeek models when thinking mode is enabled
deepseek-reasoner models
DeepSeek models with thinking: { type: "enabled" } option
Your issue describes a slightly different symptom (missing empty reasoning_content on assistant messages after the last user message), but it shares the same root area. Please review those issues and consider whether your fix addresses or overlaps with them. If this is a distinct problem, it may be worth clarifying how it differs.
I'm also experiencing this exact issue when using DeepSeek models (deepseek-v4-flash) with thinking mode enabled in OpenCode. The error "The reasoning_content in the thinking mode must be passed back to the API" occurs consistently after tool call rounds (e.g., file read/write operations).
This makes the DeepSeek thinking mode nearly unusable with tool-calling agents. Looking forward to seeing PR #17529 merged — any update on when it might be reviewed/merged?
Activity
github-actions commentedon Mar 14, 2026
This issue might be a duplicate of existing issues. Please check:
reasoning_contentnot cleared from message history on new turns — covers the sametransform.tslogic for DeepSeek thinking mode in multi-turn conversationsYour issue describes a slightly different symptom (missing empty
reasoning_contenton assistant messages after the last user message), but it shares the same root area. Please review those issues and consider whether your fix addresses or overlaps with them. If this is a distinct problem, it may be worth clarifying how it differs.bilbillm commentedon Apr 24, 2026
I'm also experiencing this exact issue when using DeepSeek models (deepseek-v4-flash) with thinking mode enabled in OpenCode. The error "The reasoning_content in the thinking mode must be passed back to the API" occurs consistently after tool call rounds (e.g., file read/write operations).
This makes the DeepSeek thinking mode nearly unusable with tool-calling agents. Looking forward to seeing PR #17529 merged — any update on when it might be reviewed/merged?
Thanks for the fix!