diff --git a/cmd/core-runtime/human_response_gate_test.go b/cmd/core-runtime/human_response_gate_test.go index 1a6c487..b5f062b 100644 --- a/cmd/core-runtime/human_response_gate_test.go +++ b/cmd/core-runtime/human_response_gate_test.go @@ -23,3 +23,15 @@ func TestShouldInvokeHumanResponseSkipsDeterministicFastPaths(t *testing.T) { }) } } + +func TestShouldReviewResponseSkipsStableAnswers(t *testing.T) { + if shouldReviewResponse("Здравствуйте.", false, true) { + t.Fatal("stable conversational reply must not wait for response review") + } + if shouldReviewResponse("Запомнил.", false, false) != true { + t.Fatal("non-conversational deterministic reply remains reviewable") + } + if shouldReviewResponse("Ответ", true, 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 3e84225..8c69e96 100644 --- a/cmd/core-runtime/main.go +++ b/cmd/core-runtime/main.go @@ -1063,7 +1063,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 strings.TrimSpace(planningReply) != "" && !stableKnowledgeReply { + if shouldReviewResponse(planningReply, stableKnowledgeReply, stableConversational) { 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,6 +1735,10 @@ func shouldInvokeHumanResponse(stableConversational bool, identityReply, memoryI return !stableConversational && identityReply == "" && memoryInstructionReply == "" } +func shouldReviewResponse(planningReply string, stableKnowledgeReply, stableConversational bool) bool { + return strings.TrimSpace(planningReply) != "" && !stableKnowledgeReply && !stableConversational +} + func shouldRunGeneralResearch(kind interaction.InformationRequestKind) bool { return kind == "" || kind == interaction.InformationRequestTimeDifference }