fix: route conversational questions to local cognition
CI / test (push) Successful in 1m5s
CI / test (pull_request) Successful in 55s

This commit is contained in:
m
2026-08-24 20:00:52 +03:00
parent 58e9c97d76
commit ba5cc60c15
3 changed files with 60 additions and 2 deletions
+13 -1
View File
@@ -468,7 +468,7 @@ func (g *gateway) handleChatMessage(w http.ResponseWriter, r *http.Request) {
saved.NeedsCognition = false
}
}
if saved.SpeechAct == interaction.SpeechActQuestion && saved.InformationRequestKind == "" && !saved.ResearchBacked && !saved.WorkPlanned && saved.Clarification != interaction.ClarificationRequired && !asksAttention(browserRequest.Message) {
if requiresVerifiedQuestion(saved, browserRequest.Message) {
reply = truthfulVerificationRequiredReply()
cognition = "verification_required"
saved.NeedsCognition = false
@@ -514,6 +514,18 @@ func (g *gateway) handleChatMessage(w http.ResponseWriter, r *http.Request) {
})
}
func requiresVerifiedQuestion(saved interaction.ChatMessageResponse, message string) bool {
if saved.SpeechAct != interaction.SpeechActQuestion || saved.InformationRequestKind != "" || saved.ResearchBacked || saved.WorkPlanned || saved.Clarification == interaction.ClarificationRequired || asksAttention(message) {
return false
}
for _, hint := range saved.CapabilityHints {
if hint == capability.CapabilityKindWebResearch || hint == capability.CapabilityKindVerifyFact {
return true
}
}
return false
}
func truthfulVerificationRequiredReply() string {
return "Я не могу сейчас подтвердить этот факт по проверенному источнику, поэтому не буду придумывать ответ. Для проверки используйте официальный сайт соответствующей службы или надёжный сервис с текущими данными; когда подключён research-маршрут, Домовой сможет проверить это сам."
}