Log inBook a Demo
BuildMidBackendAuto-graded

Validate and coerce an LLM's tool call arguments

Writing a safety layer that tolerates sloppy input from a model without letting bad data through is the exercise.An LLM has just called one of your tools and handed you an arguments object; you declared a schema for that tool. Something has to sit between the model's call and your code, because models get this wrong in small, predictable ways — emitting strings for everything, omitting fields you marked required, inventing enum values. Build the validator that coerces what can be coerced, rejects what cannot, and never mutates the caller's input.
30 min
python

You're done when

  • Values of the right shape but wrong type are coerced — a numeric string becomes a number, a boolean string becomes a boolean.
  • That coercion is genuinely applied to the returned arguments, not merely detected.
  • Enum constraints are enforced, so a value outside the declared set is rejected.
  • Required fields that are missing are reported rather than passed through as absent.
  • The input object is left unmutated — validation returns a result instead of editing the caller's data.

What it measures

Agent engineeringBuilding the boundary that makes model-generated tool calls safe to execute.
Code qualityWriting a validator that returns rather than mutates, so callers can trust their own objects afterwards.
Designing for predictable errorCoercing the deviations models reliably make, while refusing the ones that would change meaning.

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