From a57720fb29e5ed34b783c7fa60382c70d756ffda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E6=98=8E?= <83812544+Ed1s0nZ@users.noreply.github.com> Date: Thu, 9 Apr 2026 21:40:43 +0800 Subject: [PATCH] Add files via upload --- internal/handler/agent.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/handler/agent.go b/internal/handler/agent.go index 871df57c..256bb6cd 100644 --- a/internal/handler/agent.go +++ b/internal/handler/agent.go @@ -990,6 +990,24 @@ func (h *AgentHandler) createProgressCallback(conversationID, assistantMessageID return } + // 当 Agent 同时发送 thinking_stream_* 和 thinking(带同一 streamId)时, + // thinking_stream_* 已经会在 flushThinkingStreams() 聚合落库; + // 这里跳过同 streamId 的 thinking,避免 processDetails 双份展示。 + if eventType == "thinking" { + if dataMap, ok := data.(map[string]interface{}); ok { + if sid, ok2 := dataMap["streamId"].(string); ok2 && sid != "" { + if tb, exists := thinkingStreams[sid]; exists && tb != nil { + if strings.TrimSpace(tb.b.String()) != "" { + return + } + } + if flushedThinking[sid] { + return + } + } + } + } + // 保存过程详情到数据库(排除 response/done;response 正文已在 messages 表) // response_start/response_delta 已聚合为 planning,不落逐条。 if assistantMessageID != "" &&