fix: search_mode reflects actual search path, not result count#538
fix: search_mode reflects actual search path, not result count#538dstier-git wants to merge 3 commits into
Conversation
|
Thanks @dstier-git — the approach is right. The Two blockers:
Nits: type the param With line 1 repaired locally, both suites pass (101 tests) and ruff/mypy are clean — this is close. |
dstier-git
left a comment
There was a problem hiding this comment.
2 major issues to fix:
- Accidental file path paste in tools/query.py
- Lack of test coverage
|
Thanks for the review @tirth8205. Here's what I changed with #538: Issue 1 - syntax error in tools/query.py: Issue 2 - test coverage:
Nits:
|
Fixes #537
Problem
search_modeinsemantic_search_nodesis set based on whether results were returned, not which search path actually ran:This means a query where only embeddings matched reports "hybrid", and a query where embeddings silently failed (caught exception, returned empty) reports "keyword", giving no signal that semantic search never ran. Agents and users have no reliable way to tell whether the embedding path contributed.
Fix
Added an optional _out_mode: list | None = None output parameter to hybrid_search in search.py. It gets set to "hybrid", "fts", "semantic", or "keyword" based on which paths actually contributed results. All existing callers are unaffected since the parameter defaults to None.
semantic_search_nodes in tools/query.py passes _out_mode and reads from it instead of inferring from result count.
Test results
Verified by having Claude Code test queries that it would actually ask + nonsense:
"App" correctly stays "hybrid" (both FTS and embeddings matched). Multi-word natural language queries correctly report "semantic" since FTS5 phrase matching on identifier names returns nothing for those.