Not every AI feature chats. Acme uses the same model to read customer messages and pull out order details as JSON, which other code then trusts. If the model leaves out a key, invents a reason, or writes a number as text, that downstream code breaks.
The starter test only checks that each reply is valid JSON. That catches a reply cut off halfway, but nothing else.
Your task
Write a JSON Schema for the extraction and validate every reply against it with the jsonschema library. The contract the extractor must honour:
- exactly these keys:
order_id,reason,item,days_since_delivery,refund_eligible, and no others; order_id: text likeAC-12345, or null when the message has none;reason: one ofdamaged,wrong_item,changed_mind,late_delivery,other;item: text or null;days_since_delivery: a whole number of 0 or more, or null;refund_eligible: true or false.