|
| 1 | +# Tool Description Testing |
| 2 | + |
| 3 | +This directory contains tests for validating tool description quality and semantic matching capabilities. |
| 4 | + |
| 5 | +## Test Suites |
| 6 | + |
| 7 | +### 1. Description Quality Tests (`description-quality.test.ts`) |
| 8 | + |
| 9 | +Validates that tool descriptions meet quality standards: |
| 10 | + |
| 11 | +- ✅ Minimum length (>200 characters) |
| 12 | +- ✅ Includes use cases and examples |
| 13 | +- ✅ Contains relevant keywords for semantic matching |
| 14 | +- ✅ Cross-references related tools |
| 15 | +- ✅ Follows consistent structure |
| 16 | + |
| 17 | +**Run:** `npm test -- test/tools/description-quality.test.ts` |
| 18 | + |
| 19 | +### 2. Description Baseline Tests (`description-baseline.test.ts`) |
| 20 | + |
| 21 | +Prevents regression of description quality over time: |
| 22 | + |
| 23 | +- ✅ Maintains minimum word/phrase counts per tool |
| 24 | +- ✅ Preserves semantic richness (vocabulary diversity) |
| 25 | +- ✅ Ensures domain-specific terminology |
| 26 | +- ✅ Validates consistent structure patterns |
| 27 | + |
| 28 | +**Run:** `npm test -- test/tools/description-baseline.test.ts` |
| 29 | + |
| 30 | +### 3. Semantic Tool Selection Tests (`semantic-tool-selection.test.ts`) |
| 31 | + |
| 32 | +**⚠️ Requires OpenAI API Key** |
| 33 | + |
| 34 | +Validates that tool descriptions work correctly with RAG-based semantic matching using OpenAI embeddings (text-embedding-3-small model). |
| 35 | + |
| 36 | +Tests query-to-tool matching: |
| 37 | + |
| 38 | +- ✅ "find coffee shops nearby" → `category_search_tool` |
| 39 | +- ✅ "where is Starbucks" → `search_and_geocode_tool` |
| 40 | +- ✅ "driving directions" → `directions_tool` |
| 41 | +- ✅ "areas reachable in 30 minutes" → `isochrone_tool` |
| 42 | +- ✅ Category vs specific place disambiguation |
| 43 | +- ✅ Semantic similarity thresholds (>0.5 for relevant tools) |
| 44 | + |
| 45 | +#### Running Semantic Tests |
| 46 | + |
| 47 | +**Local Development:** |
| 48 | + |
| 49 | +```bash |
| 50 | +export OPENAI_API_KEY="your-key-here" |
| 51 | +npm test -- test/tools/semantic-tool-selection.test.ts |
| 52 | +``` |
| 53 | + |
| 54 | +**CI/CD:** |
| 55 | +Set `OPENAI_API_KEY` as a GitHub secret and tests will run automatically. |
| 56 | + |
| 57 | +**Without API Key:** |
| 58 | +Tests are automatically skipped if `OPENAI_API_KEY` is not set. |
| 59 | + |
| 60 | +## Test Philosophy |
| 61 | + |
| 62 | +These tests align with our RAG optimization goals: |
| 63 | + |
| 64 | +1. **Quality Tests** - Maintain description standards |
| 65 | +2. **Baseline Tests** - Prevent regressions over time |
| 66 | +3. **Semantic Tests** - Validate actual tool selection performance |
| 67 | + |
| 68 | +The semantic tests are the **core validation** that descriptions work as intended for RAG-based tool selection, while quality/baseline tests ensure consistency. |
| 69 | + |
| 70 | +## Expected Results |
| 71 | + |
| 72 | +After RAG-optimized descriptions (PR #78): |
| 73 | + |
| 74 | +- Average description length: ~1,260 characters |
| 75 | +- Vocabulary diversity: 44-52% unique words |
| 76 | +- Semantic similarity for relevant queries: >0.5 |
| 77 | + |
| 78 | +## Updating Baselines |
| 79 | + |
| 80 | +If you intentionally improve descriptions beyond current baselines, update the thresholds in `description-baseline.test.ts`: |
| 81 | + |
| 82 | +```typescript |
| 83 | +const baselines: Record< |
| 84 | + string, |
| 85 | + { minLength: number; minWords: number; minPhrases: number } |
| 86 | +> = { |
| 87 | + search_and_geocode_tool: { |
| 88 | + minLength: 800, // Update if improved |
| 89 | + minWords: 120, |
| 90 | + minPhrases: 15 |
| 91 | + } |
| 92 | + // ... |
| 93 | +}; |
| 94 | +``` |
0 commit comments