MediumAgentsPython 3
Tool Call Schema Validator
Validate tool call names and arguments before runtime execution.
35m2 sample tests3 hidden tests
Validate model-proposed tool calls against a small runtime schema.
Requirements
- Define
validate_call(call, schemas). schemasmaps tool name to a schema dict.- Each schema has
requiredand optionaloptionalfield maps. - Field type names can be
str,int,float,bool,list, ordict. - Return a list of error strings.
- Return
[]when the call is valid. - Reject unknown tools.
- Reject missing required fields.
- Reject extra fields not in required or optional maps.
- Reject wrong field types.
Example
python
1schemas = {"search": {"required": {"query": "str"}}}
2assert validate_call({"name": "search", "args": {"query": "cats"}}, schemas) == []Constraints
- Keep error order deterministic.
boolis not accepted forint.- Do not execute the tool.
Editor
Results
Run sample tests or submit all tests.