Repository navigation
Description
Background
This is a recurring pattern in NodeSpace. Prior unification work:
- Unify argument parsing between MCP handlers and agent tool executor #1060 — Unified argument parsing between MCP handlers and agent tool executor
- Fix local agent document reading (get_node markdown, search_semantic, prompt tuning) #1081 — Fixed `search_semantic` `include_markdown` hardcoded to `None`; exposed `collection` param in tool schema
- Align MCP tool descriptions with local agent guidance #1079 — Aligned MCP tool descriptions with local agent guidance
The root cause identified in #1060 comments still applies: tool definitions live in two places (`packages/core/src/mcp/handlers/search.rs` and `packages/agent/src/local_agent/tools.rs`) with no single source of truth, so drift recurs every time a param is added.
Current State
`SearchSemanticParams` (defined in `packages/core/src/mcp/handlers/search.rs`, re-exported via `packages/core/src/mcp/params.rs`) has 11 fields:
| Field | MCP handler | Local agent tool schema | Local agent executor |
|---|---|---|---|
| `query` | ✅ | ✅ | ✅ |
| `limit` | ✅ | ✅ | ✅ |
| `include_markdown` | ✅ | ✅ | ✅ (fixed in #1081) |
| `collection` | ✅ | ✅ | ✅ (fixed in #1081) |
| `threshold` | ✅ | ❌ | ❌ hardcoded to `SEMANTIC_THRESHOLD` constant |
| `scope` | ✅ | ❌ | ❌ hardcoded to `None` |
| `include_archived` | ✅ | ❌ | ❌ hardcoded to `None` |
| `node_types` | ✅ | ❌ | ❌ not wired |
| `property_filters` | ✅ | ❌ | ❌ not wired |
| `exclude_collections` | ✅ | ❌ | ❌ not wired |
| `rerank` | ✅ | ❌ | ❌ not wired |
Additionally, future enhancements from #1085 (edge context, graph scoring) will add more params that need to be exposed on both paths simultaneously.
Problem
The local agent's `exec_search_semantic` deserializes into `SearchSemanticParams` (which has all 11 fields) but then manually cherry-picks only the fields it recognizes, hardcoding the rest. Since the tool schema only declares 4 parameters, the LLM cannot request the others even if the executor were fixed.
This means the local agent has materially weaker search capability than MCP clients, and every new param added to MCP silently becomes a no-op on the local agent path until someone notices.
Proposed Changes
1. Wire all existing params through `exec_search_semantic`
In `packages/agent/src/local_agent/tools.rs`, replace the manual field extraction in `exec_search_semantic` with full pass-through of all `SearchSemanticParams` fields into `SearchSemanticInput`. Remove the hardcoded `SEMANTIC_THRESHOLD` override — use the param value, falling back to the constant only when not provided.
2. Expand `def_search_semantic` tool schema
Add the missing parameters to the JSON schema in `def_search_semantic()` so the LLM can actually use them:
- `threshold` (float, optional) — minimum similarity score
- `scope` (string enum, optional) — e.g. "workspace", "collection"
- `include_archived` (boolean, optional) — whether to include archived nodes
- `node_types` (array of strings, optional) — filter by node type
- `exclude_collections` (array of strings, optional) — collections to exclude
- `rerank` (boolean, optional) — enable reranking
`property_filters` is complex (array of objects) — assess whether it's useful enough for the LLM to express; document the decision either way.
3. Update prompts and skills
The `search_semantic` description and relevant skills (Research & Search skill, Tool Strategy Guide) need to be updated to:
- Document the new parameters with usage guidance for a local LLM
- Explain when to use `node_types` vs `collection` filtering
- Explain `threshold` tuning (when to lower it for broader recall)
- Keep guidance concise — the 8B model has limited context
Relevant files:
- `packages/agent/src/prompt_assembler.rs` — Tool Strategy Guide and system prompt
- `packages/agent/src/local_agent/skills.rs` (or equivalent) — Research & Search skill definition
4. Add parity test
Add a test that asserts every field in `SearchSemanticParams` is represented in `def_search_semantic()`'s JSON schema. This prevents future drift.
Acceptance Criteria
- All `SearchSemanticParams` fields are wired through `exec_search_semantic` (no hardcoded `None` or constant overrides)
- `def_search_semantic()` tool schema exposes all params the LLM should be able to control, with clear descriptions
- `property_filters` inclusion/exclusion is explicitly decided and documented in code comment
- Prompt and skill guidance updated to explain the new params with usage examples
- Parity test added: tool schema fields ↔ `SearchSemanticParams` fields
- Existing `search_semantic` integration tests pass
- This fix is forward-compatible with search_semantic: expose missing opt-in parameters in local agent tool and add graph-aware enhancements #1085 (new params from edge context / graph scoring should slot in without another unification pass)
Out of Scope
- Adding new search capabilities (covered by search_semantic: expose missing opt-in parameters in local agent tool and add graph-aware enhancements #1085)
- Generating tool schemas from Rust structs at build time (longer-term fix for the root cause — tracked in Unify argument parsing between MCP handlers and agent tool executor #1060 comments)
- Changes to the MCP handler path (already fully wired)
Related
- Unify argument parsing between MCP handlers and agent tool executor #1060 — Prior unification work (argument parsing)
- Fix local agent document reading (get_node markdown, search_semantic, prompt tuning) #1081 — Prior partial fix (`include_markdown`, `collection`)
- search_semantic: expose missing opt-in parameters in local agent tool and add graph-aware enhancements #1085 — Upcoming search enhancements (edge context, graph scoring, type-aware indexing)
Activity
malibio commentedon Apr 11, 2026
Frontend baseline: 128 files, 3918 tests passed (0 failed)
Fix: unify search_semantic params - wire all fields through local age…
malibio commentedon Apr 11, 2026
PR created: #1099
All acceptance criteria met:
Unify search_semantic: update prompts, fix stale comment, complete pa…
malibio commentedon Apr 14, 2026
PR #1102 merged. All 7 acceptance criteria met. Most work was done in #1085 (PR #1101); this PR completed the prompt/skill documentation and fixed the stale property_filters comment.
Fix: unify search_semantic params - wire all fields through local age…
malibio commentedon Apr 17, 2026
PR #1104 merged. All acceptance criteria met. Review passed clean.
Unify search_semantic: update prompts, fix stale comment, complete pa…
Fix: unify search_semantic params - wire all fields through local age…