From f3b588d8486c2cc460505065866728f922a307d6 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Tue, 23 Jun 2026 19:38:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=8A=E4=B8=8B=E6=96=87=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E5=8A=A024h=E5=90=88=E7=90=86=E6=80=A7=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=20=E2=80=94=20=E9=81=BF=E5=85=8D=E7=94=A8=E8=BF=9C?= =?UTF-8?q?=E5=8F=A4=E8=AE=B0=E5=BF=86=E5=BD=93=E6=9C=80=E8=BF=91=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/ai-core/internal/background/thinker.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/ai-core/internal/background/thinker.go b/backend/ai-core/internal/background/thinker.go index 2ce7955..7f2f57b 100644 --- a/backend/ai-core/internal/background/thinker.go +++ b/backend/ai-core/internal/background/thinker.go @@ -524,11 +524,14 @@ func (t *Thinker) restoreContext() { latest = m.CreatedAt } } - if !latest.IsZero() { + // Only use if reasonably recent (within 24h). Old memories don't represent user activity. + if !latest.IsZero() && time.Since(latest) < 24*time.Hour { t.mu.Lock() t.lastUserMessage = latest t.mu.Unlock() log.Printf("[后台思考] 上下文已恢复: 最近活动 %v 前", time.Since(latest).Round(time.Second)) + } else if !latest.IsZero() { + log.Printf("[后台思考] 上下文恢复跳过: 最近记忆 %v 前(>24h),使用默认值", time.Since(latest).Round(time.Second)) } }