From f0e6b7aa37984faa768c61e016fcab2aca5aed6f Mon Sep 17 00:00:00 2001 From: Liu Yuan Date: Tue, 7 Apr 2026 12:32:28 +0800 Subject: [PATCH] fix(seahorse): correct bm25 rank semantics in comments (#2360) SQLite FTS5 bm25() returns negative values where numerically smaller (more negative) indicates a better match. The official docs state: "The better the match, the numerically smaller the value returned." Two comments incorrectly stated "closer to 0 = better match" and "lower = better match". Updated all rank descriptions to use the unambiguous "more negative = higher relevance" phrasing. This matters because these comments are used as tool prompt hints for LLM agents, and incorrect semantics could lead to wrong ranking decisions. --- pkg/seahorse/short_retrieval.go | 6 +++--- pkg/seahorse/tool_grep.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/seahorse/short_retrieval.go b/pkg/seahorse/short_retrieval.go index f7d6bf691..3e94eec14 100644 --- a/pkg/seahorse/short_retrieval.go +++ b/pkg/seahorse/short_retrieval.go @@ -68,8 +68,8 @@ type GrepSummaryResult struct { Depth int `json:"depth"` Kind SummaryKind `json:"kind"` ConversationID int64 `json:"conversationId"` - // Rank is the bm25 relevance score (negative value, closer to 0 = better match). - // Examples: -0.5 = excellent match, -2.0 = good match, -10.0 = partial match. + // Rank is the bm25 relevance score (negative value, lower = better match). + // Examples: -5.0 = excellent match, -2.0 = good match, -0.5 = partial match. Rank float64 `json:"rank,omitempty"` } @@ -79,7 +79,7 @@ type GrepMessageResult struct { Snippet string `json:"snippet"` Role string `json:"role"` ConversationID int64 `json:"conversationId"` - Rank float64 `json:"rank,omitempty"` // Relevance score (lower = better match) + Rank float64 `json:"rank,omitempty"` // Relevance score (more negative = better match) } // ExpandMessagesResult contains expanded messages. diff --git a/pkg/seahorse/tool_grep.go b/pkg/seahorse/tool_grep.go index 6502fc5c3..9671d2a7f 100644 --- a/pkg/seahorse/tool_grep.go +++ b/pkg/seahorse/tool_grep.go @@ -56,8 +56,8 @@ Returns: "hint": "No matches. Try: %keyword% for fuzzy search" } -Rank field (FTS5 mode only): bm25 relevance score, negative value where closer to 0 = better match. -Examples: -0.5=excellent, -2=good, -5=partial, -10=weak. LIKE mode (%pattern%) has no rank. +Rank field (FTS5 mode only): bm25 relevance score, negative value where more negative = higher relevance. +Examples: -5=excellent, -2=good, -0.5=partial. LIKE mode (%pattern%) has no rank. Examples: {"pattern": "authentication"}