Require assistant target for renaming #381

Merged
m merged 1 commits from codex/household-travel-query-fix into main 2026-08-25 18:32:39 +00:00
2 changed files with 16 additions and 0 deletions
+10
View File
@@ -128,6 +128,9 @@ func FallbackText(act interaction.SpeechAct) string {
// of the same request.
func PreferredAssistantName(message string) string {
tokens := semanticTokens(message)
if !hasAssistantNamingTarget(tokens) {
return ""
}
for index, token := range tokens {
if !containsStem(token, "называ", "назов", "зов", "имен") {
continue
@@ -371,6 +374,9 @@ func semanticScores(tokens []string, hasQuestionMark bool, explicitCorrection bo
}
func preferredNameFromTokens(tokens []string) bool {
if !hasAssistantNamingTarget(tokens) {
return false
}
for index, token := range tokens {
if !containsStem(token, "называ", "назов", "зов", "имен") {
continue
@@ -385,6 +391,10 @@ func preferredNameFromTokens(tokens []string) bool {
return false
}
func hasAssistantNamingTarget(tokens []string) bool {
return containsToken(tokens, "тебя") || containsToken(tokens, "тебе") || containsToken(tokens, "ты")
}
// IsRetryRequest identifies a short continuation that asks Domovoy to repeat
// the previous task. It deliberately carries no subject-specific knowledge;
// the conversation owner supplies the previous task when available.
+6
View File
@@ -252,6 +252,12 @@ func TestNamingPreferenceIsSemanticAndProducesNaturalAcceptance(t *testing.T) {
if name := PreferredAssistantName("давай переименуем тебя в фею. теперь тебя зовут фея"); name != "Фея" {
t.Fatalf("rename phrase returned %q", name)
}
if name := PreferredAssistantName("назови доступные модели"); name != "" {
t.Fatalf("model inventory request was mistaken for a name: %q", name)
}
if result := BuildDeterministicCandidate("назови доступные модели", "", time.Unix(10, 0).UnixMilli()); result.PrimarySpeechAct == interaction.SpeechActPreference {
t.Fatalf("model inventory request was mistaken for a preference: %+v", result)
}
if !IsIdentityInquiry("ты кто?") || !IsIdentityInquiry("как тебя зовут") {
t.Fatal("identity variants should be recognized")
}