diff --git a/cmd/core-runtime/human_response_gate_test.go b/cmd/core-runtime/human_response_gate_test.go index d7d9e72..79de9b8 100644 --- a/cmd/core-runtime/human_response_gate_test.go +++ b/cmd/core-runtime/human_response_gate_test.go @@ -25,19 +25,22 @@ func TestShouldInvokeHumanResponseSkipsDeterministicFastPaths(t *testing.T) { } func TestShouldReviewResponseSkipsStableAnswers(t *testing.T) { - if shouldReviewResponse("Здравствуйте.", false, true, "", "") { + if shouldReviewResponse("Здравствуйте.", false, true, "", "", false) { t.Fatal("stable conversational reply must not wait for response review") } - if shouldReviewResponse("Меня зовут Домовой.", false, false, "Меня зовут Домовой.", "") { + if shouldReviewResponse("Меня зовут Домовой.", false, false, "Меня зовут Домовой.", "", false) { t.Fatal("identity reply must not wait for response review") } - if shouldReviewResponse("Запомнил.", false, false, "", "Запомнил.") { + if shouldReviewResponse("Запомнил.", false, false, "", "Запомнил.", false) { t.Fatal("memory instruction reply must not wait for response review") } - if !shouldReviewResponse("Ответ", false, false, "", "") { + if shouldReviewResponse("Вы называли тестовый цвет: синий.", false, false, "", "", true) { + t.Fatal("deterministic memory reply must not wait for response review") + } + if !shouldReviewResponse("Ответ", false, false, "", "", false) { t.Fatal("non-conversational answer remains reviewable") } - if shouldReviewResponse("Ответ", true, false, "", "") { + if shouldReviewResponse("Ответ", true, false, "", "", false) { t.Fatal("stable knowledge answer must not be reviewed twice") } } diff --git a/cmd/core-runtime/main.go b/cmd/core-runtime/main.go index f743ca0..dc41b00 100644 --- a/cmd/core-runtime/main.go +++ b/cmd/core-runtime/main.go @@ -716,6 +716,10 @@ func main() { semanticInterpretationRequested = false semanticReflexAudit = false } + if retrievedMemoryReply != "" { + semanticInterpretationRequested = false + semanticReflexAudit = false + } if identityReply != "" || memoryInstructionReply != "" { semanticReflexAudit = false } @@ -1063,7 +1067,7 @@ func main() { // route with compact, source-aware context. Re-reviewing the same answer // serially can exhaust the household request budget on a loaded local // provider and turn a valid answer into a degraded response. - if shouldReviewResponse(planningReply, stableKnowledgeReply, stableConversational, identityReply, memoryInstructionReply) { + if shouldReviewResponse(planningReply, stableKnowledgeReply, stableConversational, identityReply, memoryInstructionReply, retrievedMemoryReply != "") { reviewContext, cancelReview := context.WithTimeout(r.Context(), 12*time.Second) reviewedReply, reviewErr := cognitiveClient.ReviewResponse(reviewContext, session, utterance.Content, planningReply, gen2Context.Text, cognitive.TaskMeaning{ SpeechAct: string(semantic.Interpretation.SpeechAct), @@ -1735,8 +1739,8 @@ func shouldInvokeHumanResponse(stableConversational bool, identityReply, memoryI return !stableConversational && identityReply == "" && memoryInstructionReply == "" } -func shouldReviewResponse(planningReply string, stableKnowledgeReply, stableConversational bool, identityReply, memoryInstructionReply string) bool { - return strings.TrimSpace(planningReply) != "" && !stableKnowledgeReply && !stableConversational && identityReply == "" && memoryInstructionReply == "" +func shouldReviewResponse(planningReply string, stableKnowledgeReply, stableConversational bool, identityReply, memoryInstructionReply string, deterministicMemoryReply bool) bool { + return strings.TrimSpace(planningReply) != "" && !stableKnowledgeReply && !stableConversational && identityReply == "" && memoryInstructionReply == "" && !deterministicMemoryReply } func shouldRunGeneralResearch(kind interaction.InformationRequestKind) bool {