Bug
FTS5 search was returning wrong session content. When searching 'headless-chatgpt', the search correctly matched a child session (20260509_013938_e105c7, 156 msgs) via FTS5, but then the code fetched content from the resolved parent session (20260508_133608_740f82d1, 42 msgs) — which doesn't contain the matched text.
Root Cause
In tools/session_search_tool.py, the _resolve_to_parent helper overwrites result['session_id'] with the parent sid. Then get_messages_as_conversation(resolved_sid) fetches from the parent, not the child where the actual content lives.
# Before (buggy)
result['session_id'] = resolved_sid # ← overwrites original child sid
messages = get_messages_as_conversation(resolved_sid)
Fix
Preserve the original session ID for content retrieval, add a separate resolved_session_id field for dedup logic:
# After (fixed)
seen_sessions.add(resolved_sid)
if resolved_sid != sid:
result['resolved_session_id'] = resolved_sid
# session_id stays as original for content retrieval
messages = get_messages_as_conversation(sid)
Verification
- Child session 20260509_013938_e105c7: 156 msgs, contains 'headless-chatgpt' (13 occurrences)
- Parent session 20260508_133608_740f82d1: 42 msgs, no 'headless-chatgpt'
- After fix: content_sid correctly points to 20260509_013938_e105c7
Commit
69c55d61d — fix(session_search): use original session ID for content retrieval
Bug
FTS5 search was returning wrong session content. When searching 'headless-chatgpt', the search correctly matched a child session (20260509_013938_e105c7, 156 msgs) via FTS5, but then the code fetched content from the resolved parent session (20260508_133608_740f82d1, 42 msgs) — which doesn't contain the matched text.
Root Cause
In
tools/session_search_tool.py, the_resolve_to_parenthelper overwritesresult['session_id']with the parent sid. Thenget_messages_as_conversation(resolved_sid)fetches from the parent, not the child where the actual content lives.Fix
Preserve the original session ID for content retrieval, add a separate
resolved_session_idfield for dedup logic:Verification
Commit
69c55d61d— fix(session_search): use original session ID for content retrieval