Validate tool inputs — when the model invents arguments — step 6 of 9
The dispatcher runs the tool BEFORE validating the args. The model
passed {"q": 42} instead of {"q": "ramen"} (number instead of
string). The tool's f-string still works, but downstream the
search API rejects it with a confusing 400 error.
Fix the dispatcher to validate FIRST, then only run the tool on valid args. On failure return the error message; never let the tool see bad input.
Expected output:
ERROR: q should be str, got int
The dispatcher runs the tool BEFORE validating the args. The model
passed {"q": 42} instead of {"q": "ramen"} (number instead of
string). The tool's f-string still works, but downstream the
search API rejects it with a confusing 400 error.
Fix the dispatcher to validate FIRST, then only run the tool on valid args. On failure return the error message; never let the tool see bad input.
Expected output:
ERROR: q should be str, got int
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.