search_mode field in semantic_search_nodes reflects result count, not actual search used
(Identified on macOS with M4 chip, in Claude Code v2.1.168)
Working in both Claude Code and Codex, the search_mode field returned by calls of the semantic_search_nodes MCP tool is misleading. It's set to "hybrid" when results are non-empty and "keyword" when results are zero, regardless of which search path actually executed.
Especially concerning is the fact that this leads to "status: ok" being handed to AI agents even when empty results are caused by bugs or the user's own system issues (e.g. Numpy not available -> RuntimeError in _embedding_search).
This is not only confusing to the user but also gives AI agents poor context and sometimes leads to multiple attempts searching with similar queries.
Source (tools/query.py):
search_mode = "hybrid"
if not results:
search_mode = "keyword"
Direct Results:
- A query that matched via FTS5 only (embeddings unavailable or failed) reports "hybrid"
- A query where embeddings silently failed and returned nothing reports "keyword" but "keyword" here means "zero results", not "keyword search ran"
Confirmed — search_mode is currently set from result count, not the search path, and hybrid_search's internal fallbacks are invisible to the caller. That's a real honesty bug in the tool contract.
I've reviewed @dstier-git's #538, which plumbs the actual mode (hybrid/fts/semantic/keyword) out of hybrid_search. The design is right; it needs one accidental syntax-error line removed and regression tests asserting on search_mode (there are currently none in the repo, which is how this shipped). Details on the PR. Keeping this open until that lands.