Skip to content

search_mode field in semantic_search_nodes reflects result count, not actual search used #537

@dstier-git

Description

@dstier-git

(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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions