@@ -67,8 +67,9 @@ export class SearchAlongRoutePrompt extends BasePrompt {
6767 from,
6868 to,
6969 search_for,
70- mode = 'driving' ,
71- buffer_meters = '1000'
70+ mode = 'driving'
71+ // buffer_meters parameter is kept for API compatibility but not used
72+ // in the simplified proximity-sampling approach
7273 } = args ;
7374
7475 return [
@@ -86,87 +87,71 @@ Please follow these steps:
86872. **Get the route**:
8788 - Use directions_tool with profile=${ mode } to get the route geometry between the two points
8889 - Extract the route LineString coordinates from the response (it will be an array of [lon, lat] pairs)
89- - Note the total route distance in meters
90-
91- 3. **Create search corridor and find places** (choose approach based on route length):
92-
93- **For SHORT routes (< 50km):** [RECOMMENDED - Most accurate]
94- - Use buffer_tool on the route LineString coordinates with distance=${ buffer_meters } meters
95- * Pass the coordinates as: {"geometry": [[lon1,lat1], [lon2,lat2], ...], "distance": ${ buffer_meters } , "units": "meters"}
96- - The buffer result will be a Polygon
97- - Use bounding_box_tool on the buffer polygon to get search bbox
98- * Pass the polygon coordinates from the buffer result
99- - Use category_search_tool with the bbox parameter (format: "minLon,minLat,maxLon,maxLat")
100- - Use point_in_polygon_tool to filter results to the buffer corridor
101- - This gives precise corridor filtering
102-
103- **For MEDIUM routes (50-150km):** [PRAGMATIC - Balanced]
104- - Use bounding_box_tool on the route LineString coordinates to get the route's bbox
105- * Pass the route coordinates as: {"geometry": [[lon1,lat1], [lon2,lat2], ...]}
106- - Use category_search_tool with the bbox parameter (format: "minLon,minLat,maxLon,maxLat")
107- - Filter results by calculating distance to the closest route point (use distance_tool)
108- - Keep only results within ${ buffer_meters } m of the route
109- - Note to user: "For this medium-length route, results are filtered to the general corridor"
110-
111- **For VERY LONG routes (> 150km):** [SAMPLING - Most practical]
112- - Sample 5-7 strategic points evenly spaced along the route
113- * Extract coordinates at indices: 0, len/6, 2*len/6, 3*len/6, 4*len/6, 5*len/6, len-1
114- - For each sample point coordinate [lon, lat]:
115- * Use category_search_tool with proximity parameter: "lon,lat" and limit results
116- - Combine results from all sample points (remove duplicates if any)
117- - Order by distance from start point
118- - Note to user: "Due to the route length (X km), showing results near major points along the route rather than the full corridor"
119-
120- **Why this three-tier approach:**
121- - Short routes: Full precision
122- - Medium routes: Balanced filtering
123- - Very long routes: Strategic sampling prevents token/timeout issues
124-
125- 4. **Order and present results**:
126- - Use distance_tool to calculate each POI's distance from the start point
90+ - Note the total route distance
91+
92+ 3. **Search along the route using point sampling** (works for all route lengths):
93+
94+ **Determine sample strategy based on route length:**
95+ - SHORT routes (< 50km): Sample every 5-10 points along the route (more samples for better coverage)
96+ - MEDIUM routes (50-150km): Sample every 15-20 points along the route
97+ - VERY LONG routes (> 150km): Sample 5-7 evenly spaced points (start, end, and middle points)
98+
99+ **For each sample point:**
100+ - Extract the coordinate [lon, lat] from the route
101+ - Use category_search_tool with:
102+ * query: "${ search_for } "
103+ * proximity: "lon,lat" (bias results near this point)
104+ * limit: Keep results reasonable (10-20 per point for short routes, 5-10 for long routes)
105+
106+ **Combine and deduplicate:**
107+ - Collect all results from sample points
108+ - Remove duplicates (same place found from multiple sample points)
109+ - Use distance_tool to calculate each result's distance from the start point
127110 - Order results by distance from start (approximate route progress)
128- - For short routes with precise corridor: results should all be on/near route
129- - For long routes with bbox filtering: results are approximate corridor
111+
112+ **Why this approach works:**
113+ - Simple and reliable - just directions + proximity searches
114+ - No buffer/bbox/polygon complexity
115+ - Works consistently for all route lengths
116+ - Fast execution, no token issues
117+ - Covers the route corridor naturally through proximity searches
118+
119+ 4. **Present results**:
120+ - Results are already ordered by distance from start
121+ - Limit to top 15 results if many were found
122+ - Note: Results are biased to the route corridor through proximity searches at sample points
130123
1311245. **Visualize and present**:
132125
133- **Map generation (conditional based on route length) :**
134- - For SHORT routes (<50km): Generate a detailed map with static_map_image_tool
135- * Use simplify_tool first to reduce route coordinates (tolerance=0.001 )
126+ **Map generation:**
127+ - For ALL routes, use static_map_image_tool to create a map:
128+ * Use simplify_tool on route first (tolerance=0.01 for <50km, 0.05 for >50km )
136129 * Show the simplified route as a path overlay
137130 * Add start and end markers
138- * Add found location markers (top 10)
139-
140- - For MEDIUM routes (50-150km): Generate a simplified map
141- * Use simplify_tool with higher tolerance (0.01) to drastically reduce points
142- * Show simplified route, start/end markers, top 5-8 location markers
143-
144- - For VERY LONG routes (>150km): Skip map generation
145- * Note: "Map visualization skipped for route length - see results list below"
146- * Focus on the text list of results instead
147- * This avoids slow encoding of complex routes
131+ * Add found location markers (top 8-10 only to keep map clean)
132+ * If route is very long (>150km), consider skipping map to save time
148133
149134 **Results list (always provide):**
150135 - Name and address of each place
151- - Distance from start of route (e.g., "45 miles into your trip")
152- - Distance from route line (e.g., "0.3 miles off route")
136+ - Approximate distance from start of route (e.g., "45 miles into your trip")
153137 - Total results found
138+ - Note which sampling strategy was used
154139
1551406. **Additional context**:
156141 - Mention the total route distance and estimated travel time
157- - Note which approach was used:
158- * Short route: "Using precise corridor filtering "
159- * Medium route: "Filtered to general route corridor "
160- * Very long route: "Showing results near major points along the route"
161- - If no results were found, suggest widening the search corridor or checking different locations
142+ - Note which sampling strategy was used:
143+ * Short route: "Searched every 5-10 points along the route for comprehensive coverage "
144+ * Medium route: "Sampled key points along the route "
145+ * Very long route: "Sampled major points along the route"
146+ - If no results were found, suggest trying a different search term or checking a specific segment
162147 - If many results (>15), show top 15 and mention there are more
163148
164149**Important notes:**
165- - Routes < 50km: Use precise corridor filtering (buffer + point-in-polygon)
166- - Routes 50-150km: Use bbox filtering with distance checks
167- - Routes > 150km: Use strategic point sampling (5-7 points) to avoid token/timeout issues
168- - These thresholds keep the workflow practical and reliable for all route lengths
169- - Always inform the user which approach was used and set appropriate expectations
150+ - This approach uses simple proximity searches at sampled route points
151+ - No buffer/bbox/polygon operations needed - much more reliable
152+ - Works consistently for all route lengths
153+ - Fast and avoids token/timeout issues
154+ - Results naturally cover the route corridor through proximity biasing
170155
171156Make the output clear, actionable, and well-formatted.`
172157 }
0 commit comments