Title: Semantic search returns no results - missing threshold parameter
Semantic search in the knowledge graph always returns empty results, even when embeddings are properly stored in LanceDB.
Root Cause
The searchKnowledgeGraph function in src/tools/knowledgeGraphTools.ts calls findEntitiesBySemanticSearch with only 4 parameters, but the function signature requires 5 parameters (including threshold).
Steps to Reproduce
- Store knowledge entities using store_knowledge_memory
- Try semantic search with search_knowledge_graph with use_semantic_search: true
- Always returns empty results regardless of query
The Fix
In src/tools/knowledgeGraphTools.ts at line 264-270:
Current (broken) code: entities = await knowledgeGraph.findEntitiesBySemanticSearch( args.repository_path, args.query, args.entity_types, args.limit );
Fixed code: entities = await knowledgeGraph.findEntitiesBySemanticSearch( args.repository_path, args.query, args.entity_types, args.limit, args.threshold || 0.3 // Add missing threshold parameter );
Additional Context
- The findEntitiesBySemanticSearch method in KnowledgeGraphService.ts expects 5 parameters
- The threshold parameter defaults to 0.7 in the service but is never passed from the tool
- Embeddings are being generated and stored correctly in LanceDB
- This is a simple parameter mismatch issue
Verification
After applying this fix:
- Semantic search returns relevant results
- The threshold parameter properly controls result filtering
- Vector similarity search works as expected
Tested with ZMCPTools version: 0.3.0-jw
File: /home/jw/dev/game1/ZMCPTools/src/services/KnowledgeGraphService.ts
Issue: Empty vector results caused early return, preventing semantic search from working Fix (Line 246-250): // Commented out the early return // Don't return empty if no vector results - this prevents semantic search from working // if (entityIds.length === 0) { // return []; // }