From e83bd6febb2975b3b03dfcd2382a830f0221f53b Mon Sep 17 00:00:00 2001 From: AskaEth Date: Tue, 23 Jun 2026 21:44:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=8E=E5=8F=B0=E6=80=9D=E8=80=83?= =?UTF-8?q?=E8=AE=A9=E6=AD=A5=E5=89=8D=E5=8F=B0=20=E2=80=94=20=E7=94=A8?= =?UTF-8?q?=E6=88=B710s=E5=86=85=E6=9C=89=E6=B4=BB=E5=8A=A8=E5=88=99?= =?UTF-8?q?=E8=B7=B3=E8=BF=87=E9=9D=9Epost=5Fchat=E6=80=9D=E8=80=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/ai-core/internal/background/thinker.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/ai-core/internal/background/thinker.go b/backend/ai-core/internal/background/thinker.go index f17e3d2..d242232 100644 --- a/backend/ai-core/internal/background/thinker.go +++ b/backend/ai-core/internal/background/thinker.go @@ -1064,6 +1064,17 @@ func (t *Thinker) performThink(triggerReason string) { log.Printf("[后台思考] 开始思考周期 (触发原因=%s, 计数=%d)...", triggerReason, currentCount) + // 0. 让步于前台——如果用户最近有活动(非post_chat),跳过本次思考。 + if triggerReason != "post_chat" { + t.mu.Lock() + sinceLastUser := time.Since(t.lastUserMessage) + t.mu.Unlock() + if sinceLastUser < 10*time.Second { + log.Printf("[后台思考] 用户 %v 前有活动,让步于前台回复,跳过思考", sinceLastUser.Round(time.Second)) + return + } + } + // 1. 加载人格配置 personaConfig, err := t.personaLoader.Get("cyrene") if err != nil {