From f2f375d824a1a8d4c3c6f7171b347def5297a484 Mon Sep 17 00:00:00 2001 From: Ilker Manap Date: Sun, 27 Sep 2026 08:09:49 +0200 Subject: [PATCH] Stop the text-search comment naming one language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The choice is unchanged and now better argued: a deployment does not announce which language its notes are in, so any stemmer picked here is the wrong one somewhere — and applying the wrong one does not fail loudly, it quietly stops finding things. Co-Authored-By: Claude Opus 5 (1M context) --- internal/router/threads_test.go | 4 ++-- internal/store/migrations/postgres/0007_memory.sql | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/router/threads_test.go b/internal/router/threads_test.go index 2b7aa67..f61d310 100644 --- a/internal/router/threads_test.go +++ b/internal/router/threads_test.go @@ -113,7 +113,7 @@ func TestASystemMessageIsNeverDropped(t *testing.T) { // a forgotten turn — and much harder to spot, because the model keeps // answering. history := []store.Message{ - {Role: "system", Content: "You only answer in Turkish."}, + {Role: "system", Content: "Answer only in the user's own language."}, {Role: "user", Content: strings.Repeat("x", 500)}, {Role: "assistant", Content: strings.Repeat("y", 500)}, } @@ -126,7 +126,7 @@ func TestASystemMessageIsNeverDropped(t *testing.T) { if dropped != 2 { t.Errorf("dropped %d turns, expected both non-system ones", dropped) } - if got := strings.Join(splicedRoles(t, out), "|"); !strings.Contains(got, "only answer in Turkish") { + if got := strings.Join(splicedRoles(t, out), "|"); !strings.Contains(got, "user's own language") { t.Errorf("the system message was dropped: %s", got) } } diff --git a/internal/store/migrations/postgres/0007_memory.sql b/internal/store/migrations/postgres/0007_memory.sql index 49f0541..318bcd0 100644 --- a/internal/store/migrations/postgres/0007_memory.sql +++ b/internal/store/migrations/postgres/0007_memory.sql @@ -29,9 +29,12 @@ CREATE TABLE memory_notes ( -- Touched on every write, so retention measures how long a note has gone -- unrefreshed rather than how old it is. updated_at BIGINT NOT NULL, - -- 'simple' rather than a language configuration: these are an agent's own - -- notes, in whatever language it chose, and stemming English rules over - -- Turkish text would quietly stop finding things. + -- 'simple' rather than a language configuration. These are an agent's own + -- notes, in whatever language it chose, and a deployment does not announce + -- which that is — so any stemmer picked here is the wrong one somewhere. + -- Applying English rules to text that is not English does not fail loudly: + -- it quietly stops finding things, which is the worst way for a search to + -- be wrong. search tsvector GENERATED ALWAYS AS ( to_tsvector('simple', coalesce(key, '') || ' ' || coalesce(text, '') || ' ' || coalesce(tags, '')) ) STORED,