fix(llm): clear ReasoningEffort when DeepSeek thinking is disabled#1663
Conversation
When reasoning_effort="none" is sent to disable thinking, the DeepSeek outbound transformer correctly sets thinking.type="disabled" but fails to clear the ReasoningEffort field from the underlying OpenAI request. This causes DeepSeek API to reject the request with: reasoning_effort: unknown variant `none` Clear ReasoningEffort to empty string so it is omitted from the JSON via omitempty, leaving only thinking.type="disabled". Closes looplj#1662 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Greptile SummaryThis PR fixes a bug where sending
Confidence Score: 4/5The change is a minimal, targeted one-liner that correctly exploits the existing omitempty tag to suppress the rejected field. Safe to merge. The fix is correct and well-scoped. The only gap is that the existing test for the 'none' reasoning effort case doesn't assert that ReasoningEffort is absent from the serialized JSON, so a regression could slip through unnoticed in the future. llm/transformer/deepseek/outbound_test.go — the test covering this path should assert that ReasoningEffort is empty in the output body. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Incoming llm.Request\nReasoningEffort = 'none'] --> B[Build dsReq from oaiReq\nReasoningEffort = 'none' copied in]
B --> C{thinkingDisabled?\nReasoningEffort == 'none'}
C -- Yes --> D[Set Thinking.Type = 'disabled']
D --> E[Clear ReasoningEffort = ''\nomitempty omits from JSON]
E --> F[JSON body sent to DeepSeek\nthinking: disabled ONLY]
C -- No --> G[Set Thinking.Type = 'enabled'\nKeep ReasoningEffort as-is]
G --> H[Fill empty reasoning_content\nin assistant messages]
H --> I[JSON body sent to DeepSeek\nthinking: enabled + reasoning_effort]
F --> J[DeepSeek API accepts]
I --> J
|
There was a problem hiding this comment.
Code Review
This pull request updates the DeepSeek outbound transformer to clear the ReasoningEffort field when thinking is disabled, ensuring compatibility with the DeepSeek API by omitting unsupported values. I have no further feedback to provide.
Summary
When
reasoning_effort: "none"is sent to disable thinking mode for DeepSeek channels, the outbound transformer correctly setsthinking: {type: "disabled"}but fails to clear theReasoningEffortfield from the underlying OpenAI Request struct. This causes the JSON body sent to DeepSeek API to contain both:{ "reasoning_effort": "none", "thinking": {"type": "disabled"} }DeepSeek API rejects
reasoning_effort: "none"as unknown (only acceptshigh/low/medium/max/xhigh), returning HTTP 400.Fix
Clear
Request.ReasoningEffortto empty string when thinking is disabled, so it is omitted from JSON viaomitempty. The DeepSeek API receives onlythinking: {type: "disabled"}which correctly disables thinking.Changes
llm/transformer/deepseek/outbound.go: ClearReasonableEffortwhenthinkingDisabledis trueNote: The Anthropic-format DeepSeek path (
llm/transformer/anthropic/outbound_convert.go) was already fixed in #1552 (commit 78ab459).Closes #1662
Test plan
reasoning_effort: "none"to a DeepSeek channel via/v1/chat/completions— should return normal response without 400 errorreasoning_effort: "high"— should still enable thinking with high effort🤖 Generated with Claude Code