Validate tool inputs — when the model invents arguments — step 8 of 9
Write dispatch_with_validation(tool_name, args) that:
- Looks up
SCHEMAS[tool_name]. If missing, return"UNKNOWN_TOOL: <name>"(don't crash). - Runs
validate(args, schema). If invalid, return"VALIDATION_ERROR: <error message>". - On valid: looks up
TOOLS[tool_name], calls it with**verdict["args"], returns the result.
Three cases run for you. Expected output:
results for ramen
VALIDATION_ERROR: missing required field: q
UNKNOWN_TOOL: frobnicate
⌘↵ runs the editor.read, then continue.
Write dispatch_with_validation(tool_name, args) that:
- Looks up
SCHEMAS[tool_name]. If missing, return"UNKNOWN_TOOL: <name>"(don't crash). - Runs
validate(args, schema). If invalid, return"VALIDATION_ERROR: <error message>". - On valid: looks up
TOOLS[tool_name], calls it with**verdict["args"], returns the result.
Three cases run for you. Expected output:
results for ramen
VALIDATION_ERROR: missing required field: q
UNKNOWN_TOOL: frobnicate
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.