fix: preserve empty reasoning_content for DeepSeek V4 thinking mode - #261
Conversation
…#24146) Co-authored-by: Simon Klee <hello@simonklee.dk> (cherry picked from commit 923af96d26bd7777ae335ddade89854ac5fc8841)
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request modifies the normalizeMessages function in packages/opencode/src/provider/transform.ts to ensure that reasoning content fields are always included in the providerOptions.openaiCompatible object, even when the content is empty. This change is designed to maintain compatibility with providers like DeepSeek that require these fields to be present in subsequent requests. I have no feedback to provide as there are no review comments to evaluate.
Summary
Cherry-pick upstream opencode PR #24146 to fix DeepSeek V4 multi-turn failures when switching models mid-conversation.
Why
DeepSeek V4 thinking mode requires
reasoning_contenton every assistant message in subsequent requests. PreviouslynormalizeMessagesonly injected the field whenreasoningTextwas non-empty, so historical assistant messages produced by other models (e.g. GLM-5, GPT-4o) had noreasoning_contentand DeepSeek rejected the request with400 The reasoning_content in the thinking mode must be passed back to the API.Fix always sets the field — empty string included — so cross-model history is accepted.Related Issue
Closes #250
How To Verify
Manual repro on dev:desktop with this branch:
deepseek-v4-pro, send another message.400 reasoning_content must be passed back. After the fix: assistant replies normally withfinish=stop, reasoning tokens recorded.Verified locally via session export
pawwork-session-mighty-canyon-2026-04-27: glm-5 → deepseek-v4-pro turn completes witherror=null,finish=stop, 258 reasoning tokens preserved. CI handles broader checks.Screenshots or Recordings
N/A — backend transform fix, no UI surface.
Checklist
dev, and my PR title and commit messages use Conventional Commits in English