Skip to content

Commit 9e3ef5e

Browse files
committed
session_search: fix false-positive vector results + narrow deep search pool
Two bugs in handleSearch: 1. Vector score threshold 0.05 was too permissive — Random Projections (bag-of-words) matches generic tech queries against 'say hello' sessions at 0.30-0.36. Raised to 0.40 so only genuinely strong semantic matches pass Phase 1; everything else falls through to keyword search. 2. Deep search limited candidates to List(listLimit) = 20 recent sessions. When the last 20+ sessions are all 'say hello' heartbeats, substantive older sessions were never found. Changed to List(0) to scan all sessions.
1 parent 086f212 commit 9e3ef5e

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

cmd/odek/session_search_tool.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ func (t *sessionSearchTool) handleSearch(query string, limit int) (string, error
164164
// Load full session metadata for each result.
165165
results := make([]sessionSummary, 0, len(vecResults))
166166
for _, vr := range vecResults {
167+
// Phase 1a: Filter by similarity threshold.
168+
// Random Projections is bag-of-words, not semantic — when
169+
// 115/117 sessions are "say hello", generic tech queries
170+
// (odek, project, agent) match the hello centroid at 0.30-0.36.
171+
// A threshold of 0.40 keeps only genuinely strong matches and
172+
// falls through to keyword search for everything else.
173+
if vr.Score < 0.40 {
174+
continue
175+
}
167176
sess, err := t.store.Load(vr.SessionID)
168177
if err != nil || sess == nil {
169178
continue
@@ -190,14 +199,9 @@ func (t *sessionSearchTool) handleSearch(query string, limit int) (string, error
190199
// Vector search returned no results — fall through to keyword.
191200
}
192201

193-
// Phase 2: Keyword search (existing logic — title + deep scan).
194-
// Get generous candidate list
195-
listLimit := limit * 4
196-
if listLimit < 20 {
197-
listLimit = 20
198-
}
199-
200-
sessions, err := t.store.List(listLimit)
202+
// Phase 2: Keyword search — search ALL sessions, not just recent.
203+
// "say hello" heartbeats should not drown out older substantive sessions.
204+
sessions, err := t.store.List(0) // 0 = all sessions
201205
if err != nil {
202206
return jsonResult(sessionSearchResult{
203207
Action: "search",

0 commit comments

Comments
 (0)