fix(agent): send thinking:disabled for DeepSeek V4 and retry reasoning-only responses - #688
Open
iojaffee wants to merge 1 commit into
Open
fix(agent): send thinking:disabled for DeepSeek V4 and retry reasoning-only responses#688iojaffee wants to merge 1 commit into
iojaffee wants to merge 1 commit into
Conversation
…g-only responses
Backend agent path (structured_task_config) previously forced reasoning=auto
and never sent the DeepSeek thinking field, so deepseek-v4-flash/pro could
spend its whole max_tokens budget on reasoning_content and return an empty
content, surfacing as 'LLM response did not contain assistant content'.
- apply_openai_reasoning now mirrors the frontend (llm-providers.ts):
DeepSeek V4 endpoints get thinking:{type:disabled} on 'off', and
thinking:{type:enabled}+reasoning_effort on high/max.
- structured_task_config keeps an explicit user reasoning choice instead of
overriding it to auto (falls back to auto only when unset).
- generate/stream_openai_like retry once with thinking disabled when the
response contained only reasoning_content and no final content.
Fixes nashsu#685
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.
What
Fixes #685 — the backend agent path never sent
thinking: { type: "disabled" }for DeepSeek V4 models, sodeepseek-v4-flash/deepseek-v4-procould spend its entiremax_tokensbudget onreasoning_contentand return an emptycontent, surfacing asLLM response did not contain assistant contentin the UI chat.Root cause
Three compounding issues in
src-tauri/src/agent/provider.rs:structured_task_configforcedreasoning: auto, overriding the user's explicit reasoning choice from Settings. So even choosing "off" had no effect on backend agent turns.apply_openai_reasoningreturned early forcustomproviders, so the DeepSeek preset (provider: custom,api.deepseek.com) never received thethinkingfield the frontend sends (src/lib/llm-providers.ts:466-481).reasoning_contentwith no finalcontent, bothgenerate_openai_likeandstream_openai_likesurfaced the opaque error instead of retrying with thinking disabled (the frontend direct path already does this viaisReasoningOnlyResponseErrorinchat-panel.tsx:1197-1208).Changes
apply_openai_reasoning: mirror the frontend DeepSeek handling —thinking: {type:"disabled"}onoff;thinking: {type:"enabled"}+reasoning_effortonhigh/max; nothing onauto.structured_task_config: keep the user's explicit reasoning choice; fall back to the portableautodefault only when unset.generate_openai_like/stream_openai_like: retry once with thinking disabled when the response contained only reasoning and no final content (guarded to DeepSeek V4 endpoints only).Tests
Added 9 unit tests (all passing, 30/30 in
agent::provider):deepseek_endpoint_detection,deepseek_v4_model_detectiondeepseek_reasoning_off_sends_thinking_disableddeepseek_reasoning_high_sends_thinking_enabled_with_effortdeepseek_reasoning_auto_omits_controlsstructured_task_config_keeps_user_explicit_reasoningstructured_task_config_defaults_to_auto_when_unsetcan_retry_thinking_only_for_deepseek_v4reasoning_only_error_detectionstructured_task_config_raises_output_budget_and_keeps_explicit_reasoning(was: forced auto)Verification
Reproduced against live
api.deepseek.combefore the fix: complex agent prompt +deepseek-v4-flashstreaming → 6599 SSE chunks allreasoning_content,contentstayednull,finish_reason: length. Same prompt withthinking: {type:"disabled"}→ full content returned reliably.cargo checkand all 30 provider tests pass.