fix(openaiShim): unconditionally set reasoning_content for DeepSeek V…#918
Open
skeeminator wants to merge 1 commit intoGitlawb:mainfrom
Open
fix(openaiShim): unconditionally set reasoning_content for DeepSeek V…#918skeeminator wants to merge 1 commit intoGitlawb:mainfrom
skeeminator wants to merge 1 commit intoGitlawb:mainfrom
Conversation
…4 thinking mode DeepSeek V4 (and similar reasoning providers) require the reasoning_content field to be present on every assistant message when thinking mode is enabled — even as an empty string. The previous guard only set it when thinking text was non-empty (typeof === 'string' && trim().length > 0), causing 400 errors on multi-turn tool-call rounds. Three sites fixed in convertMessages(): - Assistant messages with thinking blocks: now always set reasoning_content (fallback to empty string when thinking text is absent) - Coalescing synthetic interrupt message: added reasoning_content: '' - String-content fallback branch: added reasoning_content: '' when preserveReasoningContent is true
Collaborator
|
Will be impacted by #910 |
Contributor
|
lets wait for #910 |
gnanam1990
approved these changes
Apr 28, 2026
Collaborator
gnanam1990
left a comment
There was a problem hiding this comment.
Tight, surgical fix. Gating behind the existing preserveReasoningContent flag keeps non-DeepSeek providers unaffected, and the three-site coverage in convertMessages matches the failure modes described. Clear repro against api.deepseek.com is appreciated. LGTM.
Optional follow-up: a unit test for the preserveReasoningContent && !thinkingText path would harden this against future regressions.
This was referenced Apr 28, 2026
Closed
3 tasks
Open
|
Omgosh, deepseek is unusable right now in OpenClaude because of this :( Will keep following until there is a merge! thanks! |
Collaborator
|
#910 merged, please rebase and fix conflicts. |
Contributor
|
hello @skeeminator kindly rebase and fix conflicts this is good to merge . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
reasoning_contentpresent on every assistant message in the request history when thinking
mode is active. The API accepts empty string — the field just needs to
exist.
reasoning_contentwhenthinkingText.trim().length > 0,so tool-call turns and edge cases (synthetic interrupts, non-array content)
sent assistant messages without the field → 400.
reasoning_contentwhenpreserveReasoningContentis true,falling back to
""when thinking text is missing. Two additional sites(coalescing interrupt, string-content else branch) now also emit the field.
Impact
API Error: 400 {"error":{"message":"The reasoning_content in the thinking mode must be passed back to the API."}}for DeepSeek V4 models (
deepseek-v4-pro,deepseek-v4-flash) againstapi.deepseek.com. Tool-call rounds and plain multi-turn now work.preserveReasoningContentflag. Non-DeepSeek providers (OpenAI, Gemini, Mistral, etc.) unaffected.
Testing
bun run buildbun run smokebun test src/services/api/openaiShim.test.tsdeepseek-v4-proagainstapi.deepseek.com—multi-turn tool-call round completed without 400
Notes
api.deepseek.com) withdeepseek-v4-pro