From d92469460261cebcdf8e5669d3ab8eaffaf66fe7 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Tue, 25 Aug 2026 04:23:00 +0300 Subject: [PATCH] Restore stable replies after cognitive routing --- cmd/core-runtime/main.go | 5 +++++ modules/interaction/domain/semantics.go | 23 ++++++++++++++++++++ modules/interaction/domain/semantics_test.go | 7 ++++++ 3 files changed, 35 insertions(+) diff --git a/cmd/core-runtime/main.go b/cmd/core-runtime/main.go index acec80c..bd20cec 100644 --- a/cmd/core-runtime/main.go +++ b/cmd/core-runtime/main.go @@ -813,6 +813,11 @@ func main() { log.Printf("cognitive response review proposed stable semantic rewrite; preserving semantic reply") } } + if !responseResult.Handled && identityReply == "" { + if stableReply, stable := interactiondomain.StableConversationalReply(utterance.Content, deterministicSpeechAct); stable { + planningReply = stableReply + } + } response := interaction.ChatMessageResponse{ ConversationID: conversation.ID, UtteranceID: utterance.ID, diff --git a/modules/interaction/domain/semantics.go b/modules/interaction/domain/semantics.go index 00ad1c6..b3c8e57 100644 --- a/modules/interaction/domain/semantics.go +++ b/modules/interaction/domain/semantics.go @@ -358,6 +358,29 @@ func semanticReply(message string, result SemanticResult, previousFocus *situati return FallbackText(result.Interpretation.SpeechAct) } +// StableConversationalReply returns the small set of low-risk conversational +// replies whose meaning must remain owned by interaction even after a sampled +// cognitive audit or a capability fast path. +func StableConversationalReply(message string, act interaction.SpeechAct) (string, bool) { + switch act { + case interaction.SpeechActConversational: + lower := strings.ToLower(message) + if strings.Contains(lower, "спасибо") || strings.Contains(lower, "благодар") { + return "Пожалуйста.", true + } + if strings.Contains(lower, "привет") || strings.Contains(lower, "здравств") { + return "Здравствуйте.", true + } + return "Я рядом.", true + case interaction.SpeechActConfirmation: + return "Хорошо.", true + case interaction.SpeechActRejection: + return "Понял.", true + default: + return "", false + } +} + func isCurrentFocusQuestion(message string, act interaction.SpeechAct) bool { if act != interaction.SpeechActQuestion { return false diff --git a/modules/interaction/domain/semantics_test.go b/modules/interaction/domain/semantics_test.go index fad992b..baa3090 100644 --- a/modules/interaction/domain/semantics_test.go +++ b/modules/interaction/domain/semantics_test.go @@ -53,6 +53,13 @@ func TestInterpretUtteranceThanksHasNaturalConversationalReply(t *testing.T) { } } +func TestStableConversationalReplySurvivesCognitiveRewrite(t *testing.T) { + reply, stable := StableConversationalReply("спасибо", interaction.SpeechActConversational) + if !stable || reply != "Пожалуйста." { + t.Fatalf("unexpected stable conversational reply: stable=%t reply=%q", stable, reply) + } +} + func TestInterpretUtteranceDirectiveRecordsOutcomeWithoutExecution(t *testing.T) { result := interpretForTest(t, "Поменяй базу на УПО1.", activeFocus("upo", "УПО"), "") if result.Interpretation.SpeechAct != interaction.SpeechActDirective { -- 2.54.0