promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_

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 break is on line 14 — but read the whole snippet first.

full-screen editor opens — close anytime to keep reading.