Avoid inheriting stale travel goals #315

Merged
m merged 2 commits from codex/chat-semantic-inventory into main 2026-08-25 02:15:16 +00:00
2 changed files with 8 additions and 1 deletions
@@ -80,6 +80,9 @@ func TestTravelSearchClarification(t *testing.T) {
if got := TravelSearchClarification("а куда летим?", history); got == "" {
t.Fatal("follow-up must remain attached to the travel goal")
}
if got := TravelSearchClarification("какая погода в Сочи?", history); got != "" {
t.Fatalf("unrelated question must not inherit travel goal, got %q", got)
}
}
func TestInterpretUtteranceDirectiveRecordsOutcomeWithoutExecution(t *testing.T) {
+5 -1
View File
@@ -30,7 +30,7 @@ func StripAssistantVocative(message string) string {
func TravelSearchClarification(message string, history []interaction.HumanUtterance) string {
current := semanticTokens(StripAssistantVocative(message))
travel := travelCue(current)
if !travel {
if !travel && travelFollowUpCue(current) {
for index := len(history) - 1; index >= 0; index-- {
if travelCue(semanticTokens(history[index].Content)) {
travel = true
@@ -62,6 +62,10 @@ func travelCue(tokens []string) bool {
return containsStemInTokens(tokens, "билет", "рейс", "поезд", "автобус", "перелет", "перелёт")
}
func travelFollowUpCue(tokens []string) bool {
return containsStemInTokens(tokens, "куда", "откуда", "маршрут", "летим", "дата", "число")
}
func hasDigit(value string) bool {
for _, runeValue := range value {
if runeValue >= '0' && runeValue <= '9' {