6/17
Part 2 of 7 · ToolsLearn and do

Check every call's arguments before anything runs

The schema tells the model what to send, and the model can still send something else. A harness checks before it runs anything.

# what issue_refund takes
REFUND_ARGS = {"order_id": str, "amount": float}


for args in ({"order_id": "A17", "amount": 189.0}, {"order_id": "A17", "amount": "189"},
             {"order_id": "A17"}, {"order_id": "A17", "amount": 189.0, "reason": "too big"}):
    print(check_args(args, REFUND_ARGS))
Predict

The model sends amount as the text "189" instead of the number 189.0. What does the check report?

Pick one to see what it prints.
Pick an answer above to see the rest