From ddb1120ee1329e1708743ccb9218c52c1a2e67e1 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Tue, 30 Jun 2026 12:41:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20buildThinkingUserPrompt=E5=B5=8C?= =?UTF-8?q?=E5=A5=97=E9=94=81=E6=AD=BB=E9=94=81=20+=20=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=BE=A4=E8=81=8A=E8=B7=AF=E7=94=B1=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - thinker.go:1662/1762 defer t.muUnlock→立即解锁,消除buildThinkingUserPrompt自死锁 (1662持锁后1762再Lock→同goroutine自死锁→23h锁泄露→3769 goroutine泄漏) - platform-bridge: 管理员在群里@别人走group_ambient而非normal,避免频繁插嘴 --- backend/ai-core/internal/background/thinker.go | 4 ++-- backend/platform-bridge/cmd/main.go | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/ai-core/internal/background/thinker.go b/backend/ai-core/internal/background/thinker.go index d271eef..b9c4764 100644 --- a/backend/ai-core/internal/background/thinker.go +++ b/backend/ai-core/internal/background/thinker.go @@ -1660,8 +1660,8 @@ func (t *Thinker) buildThinkingUserPrompt( sb.WriteString("刚有人和你聊完天。你想自然地在心里回味一下刚才的对话……\n") case "silence": t.muLock() - defer t.muUnlock() silenceDuration := time.Since(t.lastUserTime()) + t.muUnlock() sb.WriteString(fmt.Sprintf("已经大约 %s 没有说话了。你有点想知道大家在做什么……\n", formatDurationHuman(silenceDuration))) @@ -1760,7 +1760,7 @@ func (t *Thinker) buildThinkingUserPrompt( // OBv11 platform identity and available channels for proactive messaging. t.muLock() - defer t.muUnlock() + t.muUnlock() qqChannels := t.platformChannels botUIDs := t.botUIDs activeSID := t.activeSessionID diff --git a/backend/platform-bridge/cmd/main.go b/backend/platform-bridge/cmd/main.go index 1e9a8c6..8a44bd7 100644 --- a/backend/platform-bridge/cmd/main.go +++ b/backend/platform-bridge/cmd/main.go @@ -211,8 +211,16 @@ func main() { response = &bridge.UnifiedResponse{Messages: []bridge.ResponseMessage{{DisplayType: "silent"}}, Platform: msg.Platform} case isAdmin: - msg.RouteType = "normal" - response, routeErr = forwardToAICore(cfg, msg, "text", chatUserID, groupSessionID, imageURLs, videoURLs, voiceURLs, isAdmin) + // 管理员在群里@别人(非bot)时,用 group_ambient 避免昔涟频繁插嘴 + if msg.ChannelType == "group" && !isBotMentioned { + msg.RouteType = "group_ambient" + namespace := buildMemoryNamespace(msg.Platform, msg.ChannelType, msg.ChannelID) + fireSilent(namespace, imageURLs, videoURLs, voiceURLs) + response, routeErr = forwardToAICore(cfg, msg, "group_ambient", chatUserID, groupSessionID, imageURLs, videoURLs, voiceURLs, isAdmin) + } else { + msg.RouteType = "normal" + response, routeErr = forwardToAICore(cfg, msg, "text", chatUserID, groupSessionID, imageURLs, videoURLs, voiceURLs, isAdmin) + } case isBotMentioned: msg.RouteType = "normal"