Skip to content

Commit 0958e84

Browse files
Merge branch 'main' into compact-response-parameter
2 parents 1510dae + ff99f6d commit 0958e84

File tree

11 files changed

+1093
-14
lines changed

11 files changed

+1093
-14
lines changed

src/tools/category-search-tool/CategorySearchTool.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,26 @@ export class CategorySearchTool extends MapboxApiBasedTool<
1919
typeof CategorySearchResponseSchema
2020
> {
2121
name = 'category_search_tool';
22-
description =
23-
"Return all places that match a category (industry, amenity, or NAICS‑style code). Use when the user asks for a type of place, plural or generic terms like 'museums', 'coffee shops', 'electric‑vehicle chargers', or when the query includes is‑a phrases such as 'any', 'all', 'nearby'. Do not use when a unique name or brand is provided. Supports both JSON and text output formats.";
22+
description = `Search for points of interest by category or type (restaurants, gas stations, hotels, ATMs, parking, coffee shops, pharmacies, museums, hospitals, etc.). Returns a list of nearby places matching the category with coordinates, names, addresses, and details.
23+
24+
Use this when:
25+
- User asks for a type or category of place (plural/generic): "Where are the restaurants nearby?", "Show me all coffee shops"
26+
- Browsing options: "What hotels are available downtown?", "Find gas stations along this route"
27+
- Discovery queries: "What's around here?", "Show me all ATMs in this neighborhood"
28+
- Generic searches with keywords like 'any', 'all', 'nearby', 'around', 'in this area'
29+
30+
Common use cases:
31+
- Find all POIs by type: "Show me all pharmacies within 5 miles"
32+
- Browse options: "What restaurants are near Times Square?"
33+
- Amenity search: "Find EV charging stations nearby"
34+
- Service discovery: "Where are the nearest hospitals?"
35+
- Shopping: "Show me all grocery stores in downtown Seattle"
36+
37+
Difference from search_and_geocode_tool:
38+
- Use category_search_tool for types/categories (e.g., "all restaurants", "coffee shops")
39+
- Use search_and_geocode_tool for specific names/brands (e.g., "Starbucks on 5th Ave", "Empire State Building")
40+
41+
Supports both JSON and text output formats.`;
2442
annotations = {
2543
title: 'Category Search Tool',
2644
readOnlyHint: true,

src/tools/directions-tool/DirectionsTool.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,31 @@ export class DirectionsTool extends MapboxApiBasedTool<
2121
typeof DirectionsResponseSchema
2222
> {
2323
name = 'directions_tool';
24-
description =
25-
'Fetches directions from Mapbox API based on provided coordinates and direction method.';
24+
description = `Calculate optimal routes and turn-by-turn directions (navigation) between two or more locations. Returns detailed driving, walking, or cycling instructions with route geometry (path), distance, duration, and estimated travel time (ETA).
25+
26+
Supports multiple routing modes:
27+
- Driving routes with real-time traffic (car navigation, auto routing)
28+
- Walking directions (pedestrian routes, on foot)
29+
- Cycling routes (bike paths, bicycle-friendly roads)
30+
- Multiple waypoints (road trip planning, multi-stop routes)
31+
32+
Common use cases:
33+
- Get driving directions from point A to B: "How do I drive from LAX to Hollywood?"
34+
- Calculate travel time and distance: "How long to walk from Central Park to Times Square?"
35+
- Plan multi-stop routes: "Route from hotel to museum to restaurant to hotel"
36+
- Compare route options: "Show me the fastest route avoiding tolls"
37+
- Navigation with traffic: "Driving directions with current traffic conditions"
38+
39+
Returns:
40+
- Turn-by-turn instructions
41+
- Route geometry (GeoJSON path for mapping)
42+
- Total distance and duration
43+
- Step-by-step maneuvers
44+
45+
Related tools:
46+
- Use matrix_tool for travel times between many locations
47+
- Use isochrone_tool to see areas reachable within a time limit
48+
- Use search_and_geocode_tool to convert addresses to coordinates first`;
2649
annotations = {
2750
title: 'Directions Tool',
2851
readOnlyHint: true,

src/tools/isochrone-tool/IsochroneTool.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,20 @@ export class IsochroneTool extends MapboxApiBasedTool<
1616
typeof IsochroneResponseSchema
1717
> {
1818
name = 'isochrone_tool';
19-
description = `Computes areas that are reachable within a specified amount of time from a location, and returns the reachable regions as contours of Polygons or LineStrings in GeoJSON format that you can display on a map.
19+
description = `Computes areas that are reachable within a specified amount of time or distance from a location (reachability analysis, coverage area, service area). Returns the reachable regions as contours of Polygons or LineStrings in GeoJSON format that you can display on a map.
20+
2021
Common use cases:
2122
- Show a user how far they can travel in X minutes from their current location
2223
- Determine whether a destination is within a certain travel time threshold
23-
- Compare travel ranges for different modes of transportation'`;
24+
- Compare travel ranges for different modes of transportation (driving, walking, cycling)
25+
- Visualize service coverage areas for businesses or facilities
26+
- Analyze accessibility and reachability for logistics planning
27+
- Find all areas within 30-minute drive time for delivery zones
28+
29+
Returns:
30+
- GeoJSON contours showing reachable areas
31+
- Multiple time/distance bands (e.g., 10, 20, 30 minutes)
32+
- Visualizable polygons for mapping coverage`;
2433
annotations = {
2534
title: 'Isochrone Tool',
2635
readOnlyHint: true,

src/tools/matrix-tool/MatrixTool.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,29 @@ export class MatrixTool extends MapboxApiBasedTool<
1919
typeof MatrixResponseSchema
2020
> {
2121
name = 'matrix_tool';
22-
description =
23-
'Calculates travel times and distances between multiple points using Mapbox Matrix API.';
22+
description = `Calculate travel times and distances between multiple origin and destination points (one-to-many, many-to-one, or many-to-many routing). Returns a distance/duration matrix showing travel time (ETA) and distance from each origin to each destination.
23+
24+
Common use cases:
25+
- Logistics and route optimization: "Calculate travel times from warehouse to 10 delivery addresses"
26+
- Find nearest location: "Which store location is closest to this customer?"
27+
- Delivery time estimates: "How long to deliver from restaurant to multiple addresses?"
28+
- Service area analysis: "Calculate distances from office to all branch locations"
29+
- Multi-point comparison: "Compare travel times between 5 hotels and 3 attractions"
30+
31+
Supports:
32+
- One-to-many: Single origin to multiple destinations
33+
- Many-to-one: Multiple origins to single destination
34+
- Many-to-many: Multiple origins to multiple destinations
35+
- Different travel modes: driving (with traffic), walking, cycling
36+
37+
Returns:
38+
- Matrix of travel times (durations) between all point pairs
39+
- Matrix of distances between all point pairs
40+
- Efficient bulk calculations for route optimization
41+
42+
Related tools:
43+
- Use directions_tool for turn-by-turn directions for a single route
44+
- Use isochrone_tool to visualize all areas reachable within a time limit`;
2445
annotations = {
2546
title: 'Matrix Tool',
2647
readOnlyHint: true,

src/tools/reverse-geocode-tool/ReverseGeocodeTool.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,30 @@ export class ReverseGeocodeTool extends MapboxApiBasedTool<
1919
typeof GeocodingResponseSchema
2020
> {
2121
name = 'reverse_geocode_tool';
22-
description =
23-
'Find addresses, cities, towns, neighborhoods, postcodes, districts, regions, and countries around a specified geographic coordinate pair. Converts geographic coordinates (longitude, latitude) into human-readable addresses or place names. Use limit=1 for best results. This tool cannot reverse geocode businesses, landmarks, historic sites, and other points of interest that are not of the types mentioned. Supports both JSON and text output formats.';
22+
description = `Convert geographic coordinates (longitude, latitude) into human-readable addresses or place names (reverse geocoding). Returns addresses, cities, towns, neighborhoods, postal codes (zip codes), districts, regions, and countries for a specific coordinate pair.
23+
24+
Common use cases:
25+
- "What address is at these coordinates?" - Get street address from GPS location
26+
- "Where am I?" - Convert device location to readable address
27+
- "What city is this?" - Identify city/town from coordinates
28+
- "Get postal code for location" - Find zip code or postal code
29+
- "Reverse geocode map click" - Display address when user clicks on map
30+
31+
Returns information about:
32+
- Street addresses (house number and street name)
33+
- Neighborhoods and districts
34+
- Cities, towns, and villages
35+
- Postal codes and zip codes
36+
- States, provinces, and regions
37+
- Countries
38+
39+
Note: Use limit=1 for best results (most relevant match). This tool cannot reverse geocode businesses, landmarks, historic sites, and other points of interest - it only returns administrative locations and addresses.
40+
41+
Related tools:
42+
- Use search_and_geocode_tool for the opposite: convert addresses to coordinates (forward geocoding)
43+
- Use search_and_geocode_tool to find businesses or POIs by name
44+
45+
Supports both JSON and text output formats.`;
2446
annotations = {
2547
title: 'Reverse Geocode Tool',
2648
readOnlyHint: true,

src/tools/search-and-geocode-tool/SearchAndGeocodeTool.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,25 @@ export class SearchAndGeocodeTool extends MapboxApiBasedTool<
2222
typeof SearchBoxResponseSchema
2323
> {
2424
name = 'search_and_geocode_tool';
25-
description =
26-
"Search for POIs, brands, chains, geocode cities, towns, addresses. Do not use for generic place types such as 'museums', 'coffee shops', 'tacos', etc, because category_search_tool is better for that. Setting a proximity point is strongly encouraged for more local results.";
25+
description = `Search for specific points of interest (POIs), businesses, brands, landmarks, and convert addresses or place names to coordinates (geocoding). Returns detailed location information including coordinates (latitude/longitude), addresses, and place metadata.
26+
27+
Use this when:
28+
- User specifies a particular place name, brand, or business (e.g., "Starbucks on 5th Avenue", "Empire State Building")
29+
- Converting addresses to coordinates for mapping or routing
30+
- Looking up specific landmarks, buildings, or locations by name
31+
- Need precise location details for a named place
32+
33+
Common use cases:
34+
- Geocode an address: "123 Main Street, Seattle, WA" → coordinates
35+
- Find a specific business: "Find the nearest Tesla showroom"
36+
- Locate landmarks: "Where is the Statue of Liberty?"
37+
- Get coordinates for routing: "Get directions from Central Park to Times Square"
38+
39+
Related tools:
40+
- Use category_search_tool for browsing all places by type (e.g., "all restaurants nearby", "show me gas stations")
41+
- Use reverse_geocode_tool to convert coordinates back to addresses
42+
43+
Note: Do not use for generic place types like 'museums', 'coffee shops', 'tacos' - category_search_tool is better for that. Setting a proximity point is strongly encouraged for more local results.`;
2744
annotations = {
2845
title: 'Search and Geocode Tool',
2946
readOnlyHint: true,

src/tools/static-map-image-tool/StaticMapImageTool.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,33 @@ export class StaticMapImageTool extends MapboxApiBasedTool<
1414
typeof StaticMapImageInputSchema
1515
> {
1616
name = 'static_map_image_tool';
17-
description =
18-
'Generates a static map image from Mapbox Static Images API. Supports center coordinates, zoom level (0-22), image size (up to 1280x1280), various Mapbox styles, and overlays (markers, paths, GeoJSON). Returns PNG for vector styles, JPEG for raster-only styles.';
17+
description = `Generate a static map image URL from Mapbox Static Images API. Creates a snapshot/thumbnail of a map location with optional markers, paths, and overlays. Returns a direct URL to the image (PNG or JPEG format), not an embedded image.
18+
19+
Common use cases:
20+
- Create shareable map snapshots for reports or documentation
21+
- Generate thumbnail previews of locations for listings or search results
22+
- Embed map images in emails, PDFs, or presentations
23+
- Show route overview as static image
24+
- Create before/after comparison maps
25+
- Display location context in non-interactive formats
26+
27+
Supports:
28+
- Custom center coordinates and zoom level (0-22)
29+
- Image dimensions up to 1280x1280 pixels
30+
- Multiple map styles (streets, satellite, outdoors, dark, light, etc.)
31+
- Markers with custom colors and labels
32+
- Paths and polylines (routes, boundaries)
33+
- GeoJSON overlays for complex shapes
34+
35+
Output format:
36+
- Returns direct URL string to image file
37+
- PNG format for vector styles
38+
- JPEG format for raster/satellite styles
39+
- URL can be embedded in HTML, shared, or downloaded
40+
41+
Related tools:
42+
- Use directions_tool to get route geometry to display on static map
43+
- Use search_and_geocode_tool to get coordinates for map center`;
1944
annotations = {
2045
title: 'Static Map Image Tool',
2146
readOnlyHint: true,

test/tools/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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

Comments
 (0)