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
[BUG] DeepSeek error: 'reasoning_content' must be passed back to the API #201
Describe the bug
DeepSeek error: 'reasoning_content' must be passed back to the API
To Reproduce
Steps to reproduce the behavior:
Create a DeepSeek provider with deepseek-v4-pro and your API.
Set Model Reasoning Effort to High.
Run a task.
Expected behavior
I expected it to run smoothly, but I get this:
Provider Error · 400
The provider couldn't process the request as made. Stop the task and try a different approach.
Details: DeepSeek completion error: 400 The reasoning_content in the thinking mode must be passed back to the API.
The 400 error occurs because DeepSeek's thinking-mode API requires reasoning_content to be present on every assistant message in the conversation history, not just the one that immediately precedes the current request.
Why it happens:
When the conversation history contains an assistant message that lacks reasoning_content — either from a prior turn where DeepSeek generated no thinking output, or from a message generated by a different model (e.g. if you have different models configured for different modes/agents) — DeepSeek can't distinguish it from one of its own thinking-mode responses and rejects the request.
The specific code path: convertToR1Format in r1-format.ts only sets reasoning_content on assistant messages where it can extract a reasoning block from history. Messages without reasoning blocks get no reasoning_content field, which triggers the 400.
Proposed fix:
After convertToR1Format, when thinking mode is active, normalize all assistant messages that are missing reasoning_content by setting it to "". An empty string signals "no thinking this turn" rather than a missing field, which DeepSeek misreads as dropped thinking content.
This is confirmed to reproduce with mixed-model setups (e.g. DeepSeek for code mode + another model for debug mode) and in long single-model sessions where some turns produce no reasoning output.
Activity
leosdad commentedon May 19, 2026
I see now that this issue and anomalyco/opencode#24104 are probably the same. Sorry for the oversight.,
edelauna commentedon May 23, 2026
Root cause identified.
The 400 error occurs because DeepSeek's thinking-mode API requires
reasoning_contentto be present on every assistant message in the conversation history, not just the one that immediately precedes the current request.Why it happens:
When the conversation history contains an assistant message that lacks
reasoning_content— either from a prior turn where DeepSeek generated no thinking output, or from a message generated by a different model (e.g. if you have different models configured for different modes/agents) — DeepSeek can't distinguish it from one of its own thinking-mode responses and rejects the request.The specific code path:
convertToR1Formatinr1-format.tsonly setsreasoning_contenton assistant messages where it can extract a reasoning block from history. Messages without reasoning blocks get noreasoning_contentfield, which triggers the 400.Proposed fix:
After
convertToR1Format, when thinking mode is active, normalize all assistant messages that are missingreasoning_contentby setting it to"". An empty string signals "no thinking this turn" rather than a missing field, which DeepSeek misreads as dropped thinking content.This is confirmed to reproduce with mixed-model setups (e.g. DeepSeek for code mode + another model for debug mode) and in long single-model sessions where some turns produce no reasoning output.
feigou6545456 commentedon Jun 30, 2026
啥时候修复?