Log inBook a Demo
BuildMidBackendAuto-graded

Validate and coerce an LLM's tool call arguments

Check a model's tool arguments against a schema, coerce sane values like "5" and reject the ones that can't fit.A model calls one of your tools with an args dict, and you have a schema for that tool. Models send "5" for an integer and "true" for a boolean, leave out required fields and make up enum values. Write validate(args, schema) so it returns a new dict with values coerced to the declared types, nested objects and arrays included, and raises ValidationError naming the field when a value can't fit.
30 min
python

You're done when

  • Strings with the right value but the wrong type are converted: "5" becomes the integer 5 and "true" becomes True.
  • The returned dict holds the converted values, not the original strings.
  • A value outside a field's enum raises ValidationError for that field.
  • A missing required field raises ValidationError instead of being passed through.
  • The caller's args is unchanged after the call, because validate builds and returns a new dict.

What it measures

Agent engineeringChecking tool calls written by a model before your code acts on them.
Code qualityReturning a new result from `validate` and leaving the caller's data as it was.
Handling bad inputWhich model mistakes get coerced, which get rejected, and whether the error names the field.

Your environment

Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards

Start this lab

30 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo