Description
When using DeepSeek V4 models through a proxy provider like OpenCode Zen (opencode-native endpoint class), the agent gets stuck on tool calls. The root cause is that reasoning_content from the assistant's response is not preserved in follow-up requests after tool execution.
Root Cause
The DeepSeek V4 API requires reasoning_content to be echoed back in the assistant message when continuing the conversation after tool calls. If missing, it returns a 500 error.
Code Analysis
In openai-transport-stream.ts, shouldPreserveReasoningContentReplay() checks three conditions:
compat.requiresReasoningContentOnAssistantMessages — set when isDeepSeek or isXiaomi in compat detection
compat.thinkingFormat === "deepseek" — same
- Model ID in
REASONING_CONTENT_REPLAY_MODEL_IDS set
Problem 1: isDeepSeek checks endpointClass === "deepseek-native" — but when DeepSeek models are accessed through a proxy like OpenCode Zen, the endpoint class is "opencode-native", not "deepseek-native". So conditions 1 and 2 both fail.
Problem 2: The REASONING_CONTENT_REPLAY_MODEL_IDS set lists deepseek-v4-flash but not deepseek-v4-flash-free or big-pickle (also DeepSeek-based models).
Problem 3: In getCompat(), requiresReasoningContentOnAssistantMessages is hardcoded to auto-detected only, not allowing model compat override.
Suggested Fix
- Add
deepseek-v4-flash-free and big-pickle to REASONING_CONTENT_REPLAY_MODEL_IDS
- OR extend
isDeepSeek detection to recognize DeepSeek models through proxy endpoints
Steps to Reproduce
- Configure OpenCode Zen provider with
deepseek-v4-flash-free model
- Send a message requiring tool use
- Agent gets stuck after executing tools — API returns 500 about missing
reasoning_content
Description
When using DeepSeek V4 models through a proxy provider like OpenCode Zen (opencode-native endpoint class), the agent gets stuck on tool calls. The root cause is that
reasoning_contentfrom the assistant's response is not preserved in follow-up requests after tool execution.Root Cause
The DeepSeek V4 API requires
reasoning_contentto be echoed back in the assistant message when continuing the conversation after tool calls. If missing, it returns a 500 error.Code Analysis
In
openai-transport-stream.ts,shouldPreserveReasoningContentReplay()checks three conditions:compat.requiresReasoningContentOnAssistantMessages— set whenisDeepSeekorisXiaomiin compat detectioncompat.thinkingFormat === "deepseek"— sameREASONING_CONTENT_REPLAY_MODEL_IDSsetProblem 1:
isDeepSeekchecksendpointClass === "deepseek-native"— but when DeepSeek models are accessed through a proxy like OpenCode Zen, the endpoint class is"opencode-native", not"deepseek-native". So conditions 1 and 2 both fail.Problem 2: The
REASONING_CONTENT_REPLAY_MODEL_IDSset listsdeepseek-v4-flashbut notdeepseek-v4-flash-freeorbig-pickle(also DeepSeek-based models).Problem 3: In
getCompat(),requiresReasoningContentOnAssistantMessagesis hardcoded to auto-detected only, not allowing model compat override.Suggested Fix
deepseek-v4-flash-freeandbig-pickletoREASONING_CONTENT_REPLAY_MODEL_IDSisDeepSeekdetection to recognize DeepSeek models through proxy endpointsSteps to Reproduce
deepseek-v4-flash-freemodelreasoning_content