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).
  • schemas maps tool name to a schema dict.
  • Each schema has required and optional optional field maps.
  • Field type names can be str, int, float, bool, list, or dict.
  • 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.
  • bool is not accepted for int.
  • Do not execute the tool.

Editor
Results
Run sample tests or submit all tests.