knowledge_search
Search past sessions and knowledge entries using hybrid TF-IDF and semantic similarity, with scoped filters for errors, plans, configs, tools, files, and decisions.
Instructions
Search across sessions AND knowledge entries. Returns {mode, sessions, knowledge}. General mode (no scope): hybrid TF-IDF + semantic over both sources, with optional MMR diversity and category boost. Scoped mode (scope set): sessions-only filtered recall for a specific domain (errors, plans, configs, tools, files, decisions).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mmr | No | Apply Maximal Marginal Relevance re-ranking to knowledge results (default: false). Trades a small amount of top-1 relevance for diversity in the top-K. | |
| role | No | Filter by message role (default: all, ignored when scope is set) | |
| query | Yes | Search query -- supports keywords and phrases | |
| scope | No | Search scope (optional): errors (stack traces), plans (architecture, TODOs), configs (settings, env vars), tools (MCP tool calls), files (file paths, code refs), decisions (trade-offs, choices), all (no filter). When set, response mode switches to "scoped" and results are sessions-only. | |
| ranked | No | Use TF-IDF ranking (default: true, ignored when scope is set). Set false for regex mode. | |
| explain | No | When true, each knowledge hit carries `score_components` (bm25, decay, maturity, confidence, category_boost, mmr_penalty). | |
| project | No | Restrict search to sessions from this project | |
| category | No | Knowledge category hint (optional). By default applied as a boost (non-matching kept, matching +25%). Pass category_mode="filter" for the legacy hard-filter behavior. | |
| semantic | No | Blend semantic vector similarity with TF-IDF (default: true). Falls back to pure TF-IDF if embeddings unavailable. | |
| mmr_lambda | No | MMR tradeoff 0-1 (default: 0.7). 1.0 = pure relevance; 0.0 = pure diversity. | |
| max_results | No | Maximum number of results to return (default: 20) | |
| category_mode | No | How `category` is applied to knowledge results (default: "boost"). "boost" keeps all entries but gives matching-category entries a 25% score boost; "filter" restricts to matching category only. |