fix(reasoning): persist canonical history for DeepSeek and web chat

This commit is contained in:
lc6464
2026-04-24 21:45:41 +08:00
parent ccd19a48ce
commit bb0f983708
17 changed files with 1016 additions and 43 deletions
+17 -5
View File
@@ -5,6 +5,7 @@ package agent
import (
"context"
"fmt"
"maps"
"path/filepath"
"strings"
"time"
@@ -465,17 +466,28 @@ func sideQuestionResponseContent(response *providers.LLMResponse) string {
if response == nil {
return ""
}
if response.Content != "" {
if strings.TrimSpace(response.Content) != "" {
return response.Content
}
return response.ReasoningContent
return responseReasoningContent(response)
}
func responseReasoningContent(response *providers.LLMResponse) string {
if response == nil {
return ""
}
if strings.TrimSpace(response.Reasoning) != "" {
return response.Reasoning
}
if strings.TrimSpace(response.ReasoningContent) != "" {
return response.ReasoningContent
}
return ""
}
func shallowCloneLLMOptions(opts map[string]any) map[string]any {
clone := make(map[string]any, len(opts))
for k, v := range opts {
clone[k] = v
}
maps.Copy(clone, opts)
return clone
}