feat: 主动消息写回对话历史 — 防止短期重复提问
- storeThought 推送主动消息后写入 convStore - 轻量思考话题发起后也写入 - 配合提示词规则: 两小时内不重复问同类话题 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -929,6 +929,9 @@ func (t *Thinker) performLightThink() {
|
|||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
if pusher != nil && canPush {
|
if pusher != nil && canPush {
|
||||||
go pusher(t.adminUserID, sessionID, topic)
|
go pusher(t.adminUserID, sessionID, topic)
|
||||||
|
if t.convStore != nil && sessionID != "" {
|
||||||
|
t.convStore.AddMessage(sessionID, model.LLMMessage{Role: model.RoleAssistant, Content: topic})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1873,9 +1876,15 @@ func (t *Thinker) storeThought(content string, toolCallsJSON string, toolCallCou
|
|||||||
log.Printf("[后台思考] 推送平台主动消息: target=%s/%s user=%s group=%s msg=%s",
|
log.Printf("[后台思考] 推送平台主动消息: target=%s/%s user=%s group=%s msg=%s",
|
||||||
targetCopy.Platform, targetCopy.ChatType, targetCopy.UserID, targetCopy.GroupID, proactiveMsg)
|
targetCopy.Platform, targetCopy.ChatType, targetCopy.UserID, targetCopy.GroupID, proactiveMsg)
|
||||||
platformPusher(*targetCopy, proactiveMsg)
|
platformPusher(*targetCopy, proactiveMsg)
|
||||||
|
if t.convStore != nil && pushSessionID != "" {
|
||||||
|
t.convStore.AddMessage(pushSessionID, model.LLMMessage{Role: model.RoleAssistant, Content: proactiveMsg})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("[后台思考] 推送主动消息: %s", proactiveMsg)
|
log.Printf("[后台思考] 推送主动消息: %%s", proactiveMsg)
|
||||||
pusher(t.adminUserID, pushSessionID, proactiveMsg)
|
pusher(t.adminUserID, pushSessionID, proactiveMsg)
|
||||||
|
if t.convStore != nil && pushSessionID != "" {
|
||||||
|
t.convStore.AddMessage(pushSessionID, model.LLMMessage{Role: model.RoleAssistant, Content: proactiveMsg})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user