A team is building a classification system where Claude must categorize customer support tickets into one of 12 defined categories. Claude sometimes creates new categories not in the defined list. Which technique provides the strongest guarantee of constraining output to the defined taxonomy?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Here's the deal — both approaches work, but with different strength guarantees. Option C (tool use with enum parameter) provides the strongest constraint because JSON schema enums are validated at the API level — Claude cannot return a category outside the defined list without triggering a schema validation error.
Full explanation below image
Full Explanation
Both approaches work, but with different strength guarantees. Option C (tool use with enum parameter) provides the strongest constraint because JSON schema enums are validated at the API level — Claude cannot return a category outside the defined list without triggering a schema validation error. Option B (XML + prefill + few-shot) provides good reliability through prompt engineering but is a softer constraint that can be overcome in edge cases. The architecturally correct choice depends on requirements: if an invalid category is catastrophic (e.g., misroutes a critical ticket), use C; if occasional 'unclear' or 'other' classifications are acceptable, B allows that flexibility. Recognizing both as valid with distinct tradeoffs is the architect-level answer. Option A alone (list + temperature 0) is insufficient — temperature 0 doesn't prevent schema violations.