fix: 上下文恢复加24h合理性检查 — 避免用远古记忆当最近活动
This commit is contained in:
@@ -524,11 +524,14 @@ func (t *Thinker) restoreContext() {
|
|||||||
latest = m.CreatedAt
|
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.mu.Lock()
|
||||||
t.lastUserMessage = latest
|
t.lastUserMessage = latest
|
||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
log.Printf("[后台思考] 上下文已恢复: 最近活动 %v 前", time.Since(latest).Round(time.Second))
|
log.Printf("[后台思考] 上下文已恢复: 最近活动 %v 前", time.Since(latest).Round(time.Second))
|
||||||
|
} else if !latest.IsZero() {
|
||||||
|
log.Printf("[后台思考] 上下文恢复跳过: 最近记忆 %v 前(>24h),使用默认值", time.Since(latest).Round(time.Second))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user