Repository navigation
fix: fewer failed matrix_tool and map_matching_tool calls - #340
Merged
Merged
Conversation
- matrix_tool: allow null waypoints for unroutable coordinates, return a tool error instead of schema-violating structuredContent, and replace the "all coordinates used" check with the API's two-element minimum. - map_matching_tool: say it's for dense GPS traces and point to directions_tool, fix the radius default in the description, reject a radius of 0 and non-ascending timestamps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the hosted server's logs: most matrix_tool errors were one-element matrices the API refuses (944 of 1,181), then 429s (215). Map matching's were matchings without geometry from overview=false (10 of 16). - matrix_tool: ask for a 1x2 matrix for a single pair and return only that pair; explain the rate limit in the description and on a 429. - map_matching_tool: geometry is optional; radiuses go up to 50, which the API enforces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jussi-sa
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Claude directory shows 6.8% of
matrix_toolcalls and 15.1% ofmap_matching_toolcalls failing. The hosted server's CloudWatch logs (hosted-mcp-server-production-us-east-1, last 30 days) break it down:matrix_toolmap_matching_toolgeometry), the rest one-offsI reproduced each cause below against the live APIs.
matrix_tool
sources=0&destinations=1), which is one matrix element, and the API refuses it:422: ... only 1 matrix element; minimum number of matrix elements is 2. The tool now requests a 1×2 matrix (destinations=i;j, the source to itself and to the destination), the API's minimum, so it costs the same, and returns only the requested pair. Checked live in both directions.driving-traffic). The pipeline already retries 429s, but only for a few seconds. The description and the 429 error now tell the model to put all the points in one call (up to 25) instead of one call per pair, which is probably what's tripping the limit.sourcesanddestinationsset, it required every coordinate to be used. The API has no such rule, so that check is gone. A source that is also its only destination is still refused before the call.nullinsources/destinations. Our schema didn't allownull, and the tool returned the raw response anyway, so SDK v2 threw an output validation error.nullwaypoints are now allowed, and the result notes which coordinates couldn't be snapped. A response that still fails the schema is now a tool error, as fix: map_matching_tool returns graceful error instead of MCP -32602 on NoMatch #230 did for map matching. This didn't show up in the 30 days of logs, but it's a real failure.map_matching_tool
overview=false(10 of 16 errors). The API leaves outgeometrythen, and our output schema required it. It's optional now.NoMatch, 20 km+ gives422 All coordinates are too far away from each other. The description and both errors now point todirections_tool.must be ... greater than 0 and smaller than 50), so the schema now takes > 0 and ≤ 50.NoMatch, are rejected.Not changed
A few input validation errors (coordinates sent as
[lng, lat]arrays, an unknown profile) come from the model, not the tool. They're 1–3 each.Tests
NoMatchhint.🤖 Generated with Claude Code