Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Go: disable thinking for search ask summary to fix truncated AI summary (#17155)

euvre87417d083ef8
diff --git a/internal/entity/models/openai.go b/internal/entity/models/openai.go
index 46b52df406..9f17895be0 100644
--- a/internal/entity/models/openai.go
+++ b/internal/entity/models/openai.go
@@ -124,10 +124,14 @@ func (o *OpenAIModel) ChatWithMessages(modelName string, messages []Message, api
}
}
- // Qwen3 family: disable thinking by default (matches Python's
- // _apply_model_family_policies in rag/llm/chat_model.py:119-121).
- if strings.Contains(strings.ToLower(modelName), "qwen3") && (chatModelConfig == nil || chatModelConfig.Thinking == nil) {
- reqBody["enable_thinking"] = false
+ // Qwen3 family: disable thinking unless explicitly enabled (matches
+ // Python's _apply_model_family_policies in rag/llm/chat_model.py:119-121).
+ if strings.Contains(strings.ToLower(modelName), "qwen3") {
+ if chatModelConfig != nil && chatModelConfig.Thinking != nil {
+ reqBody["enable_thinking"] = *chatModelConfig.Thinking
+ } else {
+ reqBody["enable_thinking"] = false
+ }
}
jsonData, err := json.Marshal(reqBody)
@@ -302,9 +306,13 @@ func (o *OpenAIModel) ChatStreamlyWithSender(modelName string, messages []Messag
}
}
- // Qwen3 family: disable thinking by default.
- if strings.Contains(strings.ToLower(modelName), "qwen3") && (chatModelConfig == nil || chatModelConfig.Thinking == nil) {
- reqBody["enable_thinking"] = false
+ // Qwen3 family: disable thinking unless explicitly enabled.
+ if strings.Contains(strings.ToLower(modelName), "qwen3") {
+ if chatModelConfig != nil && chatModelConfig.Thinking != nil {
+ reqBody["enable_thinking"] = *chatModelConfig.Thinking
+ } else {
+ reqBody["enable_thinking"] = false
+ }
}
jsonData, err := json.Marshal(reqBody)
diff --git a/internal/service/ask_service.go b/internal/service/ask_service.go
index c5c1fbe008..40ef84a453 100644
--- a/internal/service/ask_service.go
+++ b/internal/service/ask_service.go
@@ -186,7 +186,12 @@ func (s *AskService) run(ctx context.Context, llm StreamingLLM, userID, question
{Role: "system", Content: sysPrompt},
{Role: "user", Content: question},
}
- genConf := &modelModule.ChatConfig{Temperature: ptrFloat64(0.1)}
+ // Thinking is disabled: summarization does not need reasoning. With
+ // thinking enabled, the reasoning (which drafts the summary) streams
+ // first, then collapses into a hidden think block, and the provider may
+ // emit only a fragment as the visible answer once the reasoning has
+ // consumed the output budget.
+ genConf := &modelModule.ChatConfig{Temperature: ptrFloat64(0.1), Thinking: ptrBool(false)}
ch, err := llm.ChatStream(ctx, messages, genConf)
if err != nil {
@@ -279,3 +284,4 @@ func toFloat64Slice(v interface{}) []float64 {
func ptrInt(v int) *int { return &v }
func ptrFloat64(v float64) *float64 { return &v }
+func ptrBool(v bool) *bool { return &v }