Restore stable replies after cognitive routing #309

Merged
m merged 2 commits from codex/chat-semantic-inventory into main 2026-08-25 01:28:07 +00:00
3 changed files with 35 additions and 0 deletions
+5
View File
@@ -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,
+23
View File
@@ -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
@@ -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 {