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 anargs 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"becomesTrue. - The returned dict holds the converted values, not the original strings.
- A value outside a field's
enumraisesValidationErrorfor that field. - A missing required field raises
ValidationErrorinstead of being passed through. - The caller's
argsis unchanged after the call, becausevalidatebuilds 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
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish
Start this lab
30 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo