fix: buildThinkingUserPrompt嵌套锁死锁 + 管理员群聊路由优化

- thinker.go:1662/1762 defer t.muUnlock→立即解锁,消除buildThinkingUserPrompt自死锁
  (1662持锁后1762再Lock→同goroutine自死锁→23h锁泄露→3769 goroutine泄漏)
- platform-bridge: 管理员在群里@别人走group_ambient而非normal,避免频繁插嘴
This commit is contained in:
2026-06-30 12:41:24 +08:00
parent 88755e131a
commit ddb1120ee1
2 changed files with 12 additions and 4 deletions
@@ -1660,8 +1660,8 @@ func (t *Thinker) buildThinkingUserPrompt(
sb.WriteString("刚有人和你聊完天。你想自然地在心里回味一下刚才的对话……\n") sb.WriteString("刚有人和你聊完天。你想自然地在心里回味一下刚才的对话……\n")
case "silence": case "silence":
t.muLock() t.muLock()
defer t.muUnlock()
silenceDuration := time.Since(t.lastUserTime()) silenceDuration := time.Since(t.lastUserTime())
t.muUnlock()
sb.WriteString(fmt.Sprintf("已经大约 %s 没有说话了。你有点想知道大家在做什么……\n", sb.WriteString(fmt.Sprintf("已经大约 %s 没有说话了。你有点想知道大家在做什么……\n",
formatDurationHuman(silenceDuration))) formatDurationHuman(silenceDuration)))
@@ -1760,7 +1760,7 @@ func (t *Thinker) buildThinkingUserPrompt(
// OBv11 platform identity and available channels for proactive messaging. // OBv11 platform identity and available channels for proactive messaging.
t.muLock() t.muLock()
defer t.muUnlock() t.muUnlock()
qqChannels := t.platformChannels qqChannels := t.platformChannels
botUIDs := t.botUIDs botUIDs := t.botUIDs
activeSID := t.activeSessionID activeSID := t.activeSessionID
+8
View File
@@ -211,8 +211,16 @@ func main() {
response = &bridge.UnifiedResponse{Messages: []bridge.ResponseMessage{{DisplayType: "silent"}}, Platform: msg.Platform} response = &bridge.UnifiedResponse{Messages: []bridge.ResponseMessage{{DisplayType: "silent"}}, Platform: msg.Platform}
case isAdmin: case 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" msg.RouteType = "normal"
response, routeErr = forwardToAICore(cfg, msg, "text", chatUserID, groupSessionID, imageURLs, videoURLs, voiceURLs, isAdmin) response, routeErr = forwardToAICore(cfg, msg, "text", chatUserID, groupSessionID, imageURLs, videoURLs, voiceURLs, isAdmin)
}
case isBotMentioned: case isBotMentioned:
msg.RouteType = "normal" msg.RouteType = "normal"