Every tool advertises a schema describing its arguments: which are required, what type each has, which values are allowed. The model reads the schema when deciding how to call the tool, but nothing forces it to comply, so the executor must validate the arguments before running anything with side effects. A small subset of JSON Schema covers most tools: a type for each property (string, integer, number, boolean, array), an optional list of allowed values (enum) and optional minimum and maximum for numbers. The error messages are part of the contract because they are fed back to the model so that it can fix its call.
Implement validate_arguments.
schema has properties (name to spec with type and optional enum, minimum, maximum) and required (list of names). Return a sorted list of error strings, empty when valid.missing: {name} for each required name absent from args; unexpected: {name} for each argument not in properties; type: {name} when the value has the wrong type; enum: {name} when the value is not in enum; range: {name} when a number is below minimum or above maximum.integer accepts int but not bool; number accepts int or float but not bool; string, boolean and array accept str, bool and list respectively.enum and range only if the type is correct. Report at most one of type, enum, range per argument.isinstance(True, int) is True in Python, so test for bool first.
Return sorted(errors) so the result does not depend on iteration order.
No results yet
Run your code to check it against the examples, or submit to run every test.