fix: 主动消息频控从30分钟降到5分钟 + 拦截后清除标记防止LLM幻觉
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user