From 6490c341e559855d75ffc8b4da996b484aeb4ceb Mon Sep 17 00:00:00 2001 From: AskaEth Date: Sun, 28 Jun 2026 16:34:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=BB=E5=8A=A8=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=A2=91=E6=8E=A7=E4=BB=8E30=E5=88=86=E9=92=9F=E9=99=8D?= =?UTF-8?q?=E5=88=B05=E5=88=86=E9=92=9F=20+=20=E6=8B=A6=E6=88=AA=E5=90=8E?= =?UTF-8?q?=E6=B8=85=E9=99=A4=E6=A0=87=E8=AE=B0=E9=98=B2=E6=AD=A2LLM?= =?UTF-8?q?=E5=B9=BB=E8=A7=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/ai-core/internal/background/thinker.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/ai-core/internal/background/thinker.go b/backend/ai-core/internal/background/thinker.go index 50d0e26..c8ed50f 100644 --- a/backend/ai-core/internal/background/thinker.go +++ b/backend/ai-core/internal/background/thinker.go @@ -511,7 +511,7 @@ func NewThinker( lightThinkEnabled: cfg.LightThinkEnabled, lightThinkInterval: cfg.LightThinkInterval, silenceTimeout: cfg.SilenceTimeout, - proactiveMsgMinGap: getEnvDuration("PROACTIVE_MSG_MIN_GAP_SEC", 1800), + proactiveMsgMinGap: getEnvDuration("PROACTIVE_MSG_MIN_GAP_SEC", 300), postChatDelay: cfg.PostChatDelay, minThinkGap: cfg.MinThinkGap, offlineThinkGap: cfg.OfflineThinkGap, @@ -1956,7 +1956,7 @@ func (t *Thinker) storeThought(content string, toolCallsJSON string, toolCallCou } } else if canPush { gapSinceLast := time.Since(t.lastProactiveTime()) - if gapSinceLast < 30*time.Minute { + if gapSinceLast < t.proactiveMsgMinGap { log.Printf("[后台思考] 主动消息距上次仅 %v,跳过推送", gapSinceLast.Round(time.Second)) canPush = false } else { @@ -1965,6 +1965,11 @@ func (t *Thinker) storeThought(content string, toolCallsJSON string, toolCallCou } } } + // 被拦截的主动消息:清除标记,防止 LLM 下次以为发过了 + if !canPush && proactiveMsg != "" { + content = strings.ReplaceAll(content, "【主动消息】", "【未发送】") + content = strings.ReplaceAll(content, "【话题发起】", "【未发送】") + } // Copy target for use after unlock (avoid race). var targetCopy *ProactiveTarget if proactiveTarget != nil {