Question 23
Domain 3You are extracting data from insurance claims forms. The schema requires a `claim_type` field with enum values: `["medical", "dental", "vision", "mental_health", "pharmacy"]`. Validation shows Claude is occasionally returning `"Mental Health"` (capitalized, with space) instead of `"mental_health"`. Which two changes together guarantee this never happens?
Correct answer: B
Explanation
Setting "strict: true" on the tool definition makes the model follow the schema exactly, so invalid values are rejected at generation time. Including the enum in the JSON schema constrains `claim_type` to the listed values, so anything like "Mental Health" that deviates from "mental_health" is rejected before your validation code sees it.
Why each option is right or wrong
A. Add "use lowercase with underscores" to the prompt and add a few-shot example of the correct enum value
Prompt wording and examples improve compliance, but cannot guarantee exact enum-only output every time.
B. Set `strict: true` on the tool definition (schema validation guaranteed) AND include the enum in the JSON schema definition — any response deviating from the enum values will be rejected before it reaches your validation code
Under the tool-calling schema rules, `strict: true` on the tool definition enables hard schema enforcement, so the model cannot emit a value outside the declared JSON Schema. The `claim_type` property must also be declared with an `enum` of the five allowed strings in the schema itself; that makes `
C. Add a post-processing step that normalizes strings to the expected enum format
Normalization fixes bad outputs after generation; it does not prevent invalid values from being produced.
D. Use a different model that has better enum adherence
A stronger model may reduce mistakes, but model choice alone does not create deterministic schema enforcement.