From 9876c13ea8f10319a526ecc222b48e04b231ceb0 Mon Sep 17 00:00:00 2001 From: Sergey Kozyrenko Date: Fri, 10 Jul 2026 17:02:21 +0700 Subject: [PATCH] docs(providers): restore the DeepSeek legacy reasoning-format contract The openai-compat consolidation dropped the comment warning that DeepSeek needs the legacy top-level "reasoning_effort" string form; without it a maintainer could add openai.WithModernReasoningFormat() to the shared opts and silently break DeepSeek thinking mode. Restore it at the shared opts choke point. Also fix two stale pointers: glm/qwen config.yml cited WithPreserveReasoningContent() "in glm.go/qwen.go", but it moved to openaicompat.go during that same consolidation. Co-Authored-By: Claude Opus 4.8 --- backend/pkg/providers/glm/config.yml | 2 +- backend/pkg/providers/openaicompat/openaicompat.go | 4 ++++ backend/pkg/providers/qwen/config.yml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/pkg/providers/glm/config.yml b/backend/pkg/providers/glm/config.yml index 9e4da043..3f8ca8dc 100644 --- a/backend/pkg/providers/glm/config.yml +++ b/backend/pkg/providers/glm/config.yml @@ -10,7 +10,7 @@ # on the standard API endpoint Z.AI defaults to clearing reasoning_content between # turns, which hurts agent loops with tool calls. Setting clear_thinking=false # preserves reasoning_content across turns, improving reasoning continuity and cache -# hit rates. Required together with WithPreserveReasoningContent() in glm.go so that +# hit rates. Required together with WithPreserveReasoningContent() in openaicompat.go so that # langchaingo serializes reasoning_content back to the API. # # Note: langchaingo's IsReasoningModel matches glm-4.5/4.6/4.7 prefixes and force- diff --git a/backend/pkg/providers/openaicompat/openaicompat.go b/backend/pkg/providers/openaicompat/openaicompat.go index e61084d2..b5f7ad70 100644 --- a/backend/pkg/providers/openaicompat/openaicompat.go +++ b/backend/pkg/providers/openaicompat/openaicompat.go @@ -60,6 +60,10 @@ func New( openai.WithBaseURL(spec.ServerURL), openai.WithHTTPClient(httpClient), } + // Do NOT add openai.WithModernReasoningFormat() to these shared opts: DeepSeek's + // API requires the legacy top-level "reasoning_effort" string, which langchaingo + // emits only while ModernReasoningFormat is off (the default). The modern + // "reasoning":{} object form breaks DeepSeek thinking mode. if spec.PreserveReasoning { opts = append(opts, openai.WithPreserveReasoningContent()) } diff --git a/backend/pkg/providers/qwen/config.yml b/backend/pkg/providers/qwen/config.yml index d2374bd2..0ed37d09 100644 --- a/backend/pkg/providers/qwen/config.yml +++ b/backend/pkg/providers/qwen/config.yml @@ -16,7 +16,7 @@ # - preserve_thinking=true: keeps reasoning_content from previous assistant turns # in subsequent requests. Supported ONLY by qwen3.7-max and qwen3.6-plus families. # Required for agent loops with tool calls to preserve reasoning continuity. -# Works together with WithPreserveReasoningContent() in qwen.go. +# Works together with WithPreserveReasoningContent() in openaicompat.go. # - qwen3-coder-* (coder, installer) are NOT hybrid thinking models — no thinking # control needed.