semantic_search
Describe the concept you need in natural language, and retrieve code symbols that match semantically, even without exact keywords.
Instructions
Read-only. Semantic search using pre-computed symbol embeddings.
Finds symbols conceptually related to a natural-language query, even when
the query words don't appear literally in the code. Uses cosine similarity
over 1024-dimensional embeddings generated during fw-context index.
When to prefer over search_code: When you're describing a concept rather than searching for a known keyword. Examples:
"parcel locker state"finds door-state and shipment methods even though "parcel" and "locker" don't appear in their names."cell modem"finds_socket_tandModemMsg*classes."delivery box"findsset_shipmentandget_zrtdata."power consumption"findsget_load_powerand INA260 class.
When to prefer search_code instead: When you know the exact keyword
or symbol name ("fram_write", "cbor encode"). FTS5 is faster
and more precise for lexical matches.
Threshold guidance (mxbai-embed-large model):
0.50— exploratory: more results, lower precision0.55— balanced (default, ~1000 results)0.60— precise: ~175 avg, high precision0.65— strict: few results, may miss relevant symbols
Source-aware ranking: Project code (src/) boosted 1.2×,
library code (lib/) 1.1×, vendored SDK (mbed-os/) 0.85×.
Requires Ollama with an embedding model (mxbai-embed-large).
Falls back to search_code with a warning if Ollama is unavailable.
Args: query: Natural language description of what you're looking for. Be specific — 5–15 words works best. project_root: Project root. Auto-detected if omitted. threshold: Minimum cosine similarity (0.0-1.0). Default 0.60. limit: Maximum number of results (default 20, max 100).
Returns:
list of dicts, each with: name, qualified_name, kind, file, line,
is_definition, signature, docstring, plus _similarity (cosine
similarity score) and _method ("embedding" or
"search_code_fallback").
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum results (default 20, max 100). | |
| query | Yes | Natural language description, 5-15 words. E.g. 'parcel locker state machine' or 'how does the modem connect?'. | |
| threshold | No | Minimum cosine similarity (0.0-1.0). Default 0.60. Use 0.55 for exploratory, 0.50 for broad search. | |
| project_root | No | Project root. Auto-detected if omitted. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |