Description
Description
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
Related Issues/PRs
#9397, #5577,
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Description
Description
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_contentfield. 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
deepseek-reasonermodel, or any DeepSeek model withthinking: { type: "enabled" }option)reasoning_contentset, when previously empty.Expected Behavior
ALL assistant messages after the last user message should have an empty
reasoning_contentfield 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_contentfield. Assistant messages with empty reasoning content after the last user message did not have the field set.Root Cause
The
ProviderTransform.messagefunction inpackages/opencode/src/provider/transform.tsonly addedreasoning_contentwhen there was actual reasoning text present, but deepseek requires also empty "" reasoning_content fields.Solution
Modified the logic to:
reasoning_contentfieldAffected Models
deepseek-reasonermodelsthinking: { type: "enabled" }optionRelated Issues/PRs
#9397, #5577,
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response