diff --git a/backend/ai-core/internal/background/thinker.go b/backend/ai-core/internal/background/thinker.go index d6b166c..202befa 100644 --- a/backend/ai-core/internal/background/thinker.go +++ b/backend/ai-core/internal/background/thinker.go @@ -1987,8 +1987,24 @@ func (t *Thinker) storeThought(content string, toolCallsJSON string, toolCallCou t.convStore.AddMessage(pushSessionID, model.LLMMessage{Role: model.RoleAssistant, Content: proactiveMsg}) } } else { - log.Printf("[后台思考] 推送主动消息: %%s", proactiveMsg) + log.Printf("[后台思考] 推送主动消息: %s", proactiveMsg) pusher(t.adminUserID, pushSessionID, proactiveMsg) + // 同步推送到 QQ 私聊 + if platformPusher != nil { + t.mu.Lock() + channels := t.platformChannels + t.mu.Unlock() + for _, ch := range channels { + if ch.ChannelType == "direct" { + uid := strings.TrimPrefix(ch.ChannelID, "private_") + target := ProactiveTarget{Platform: ch.AdapterName, ChatType: "private", UserID: uid} + if target.Platform == "" { target.Platform = ch.Platform } + log.Printf("[后台思考] 同步推送主动消息到平台: %s/%s user=%s", target.Platform, target.ChatType, target.UserID) + platformPusher(target, proactiveMsg) + break + } + } + } if t.convStore != nil && pushSessionID != "" { t.convStore.AddMessage(pushSessionID, model.LLMMessage{Role: model.RoleAssistant, Content: proactiveMsg}) } diff --git a/backend/ai-core/internal/context/builder.go b/backend/ai-core/internal/context/builder.go index fd39f82..c779067 100644 --- a/backend/ai-core/internal/context/builder.go +++ b/backend/ai-core/internal/context/builder.go @@ -91,7 +91,11 @@ func (cs *ConversationStore) saveToDB(sessionID string, msg model.LLMMessage) { sessionID, string(msg.Role), msg.Content, msg.Timestamp, ) if err != nil { - logger.Printf("[context] saveToDB insert error: %v", err) + logger.Printf("[context] saveToDB insert error: %v (session=%s)", err, sessionID) + } + // 只对非心跳消息打日志 + if len(msg.Content) > 5 { + logger.Printf("[context] saveToDB ok: session=%s role=%s len=%d", sessionID, msg.Role, len(msg.Content)) } }