Bug Description
When using DeepSeek V4 with OpenCode, multi-turn conversations fail with the error:
The reasoning_content in the thinking mode must be passed back to the API
Steps to Reproduce
- Configure DeepSeek V4 in
opencode.json:
"deepseek": {
"npm": "@ai-sdk/openai-compatible",
"name": "DeepSeek",
"options": {
"baseURL": "https://api.deepseek.com",
"apiKey": "sk-xxx"
},
"models": {
"deepseek-reasoner": {
"name": "DeepSeek-V4",
"limit": {
"context": 1048576,
"output": 262144
}
}
}
}
- Start a conversation with DeepSeek V4
- Send a second message in the same conversation
- Error occurs
Expected Behavior
Multi-turn conversations should work seamlessly, with reasoning_content properly preserved between turns.
Actual Behavior
The conversation fails because @ai-sdk/openai-compatible doesn't preserve reasoning_content from DeepSeek's thinking mode responses.
Environment
- OpenCode version: Latest
- DeepSeek model: deepseek-reasoner (V4)
- SDK: @ai-sdk/openai-compatible
Root Cause
DeepSeek V4 enables thinking mode by default and returns reasoning_content in responses. The OpenAI-compatible SDK doesn't handle this field, causing it to be lost between conversation turns.
Workaround
Switch to Anthropic API format, which natively supports reasoning modes:
"deepseekv4": {
"npm": "@ai-sdk/anthropic",
"name": "DeepSeek",
"options": {
"baseURL": "https://api.deepseek.com/anthropic",
"apiKey": "sk-xxx"
},
"models": {
"deepseek-v4-pro": {
"name": "DeepSeek-V4-Pro",
"limit": {
"context": 1048576,
"output": 262144
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
}
}
}
This configuration:
- Uses
@ai-sdk/anthropic instead of @ai-sdk/openai-compatible
- Points to DeepSeek's Anthropic-compatible endpoint
- Properly preserves reasoning_content across conversation turns
- Allows explicit thinking mode configuration
Alternative Solutions
Community members have also suggested using transformRequestBody hooks to manually preserve reasoning_content, but the Anthropic API approach is cleaner and officially supported.
References
Bug Description
When using DeepSeek V4 with OpenCode, multi-turn conversations fail with the error:
Steps to Reproduce
opencode.json:Expected Behavior
Multi-turn conversations should work seamlessly, with reasoning_content properly preserved between turns.
Actual Behavior
The conversation fails because
@ai-sdk/openai-compatibledoesn't preservereasoning_contentfrom DeepSeek's thinking mode responses.Environment
Root Cause
DeepSeek V4 enables thinking mode by default and returns
reasoning_contentin responses. The OpenAI-compatible SDK doesn't handle this field, causing it to be lost between conversation turns.Workaround
Switch to Anthropic API format, which natively supports reasoning modes:
This configuration:
@ai-sdk/anthropicinstead of@ai-sdk/openai-compatibleAlternative Solutions
Community members have also suggested using
transformRequestBodyhooks to manually preserve reasoning_content, but the Anthropic API approach is cleaner and officially supported.References