Courseiva

CCAR-F Prompt Engineering and Structured Output Practice Question

A developer is extracting line items from invoices. The prompt includes a schema and examples, yet Claude occasionally invents field names not in the schema. Which change most directly prevents hallucinated field names?

⚠ Common exam trap

The trap here is thinking that more examples or a strict instruction eliminates invented fields, when only schema-enforced tool use constrains the allowed key set.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Define the extraction schema as a tool 'input_schema' and force tool use.

Expressing the extraction schema as a tool 'input_schema' and forcing tool use constrains Claude's output to the defined fields. Because the API validates the tool call input against the schema, invented field names are structurally prevented. This is stronger than examples, temperature tuning, or negative instructions, which only influence behavior probabilistically.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Lower the temperature to 0 to reduce randomness in field name selection.

    Why it's wrong here

    Temperature 0 makes the model more deterministic but does not restrict it to the schema's field names. It could consistently choose the same wrong key. Determinism is not the same as correctness; without a structural constraint, the model can still produce a field name outside the allowed set.

  • ✗

    Add more few-shot examples showing correct field names.

    Why it's wrong here

    More examples can improve consistency but do not constrain the model's output space. Claude may still generate a plausible but incorrect field name when the input is unusual. Examples guide behavior probabilistically, whereas schema enforcement in a tool definition restricts the allowed keys structurally, which is what prevents invented field names.

  • ✗

    Instruct Claude in the system prompt to 'never add fields not in the schema'.

    Why it's wrong here

    A negative instruction is a soft guideline that the model may not follow in every case, especially with noisy invoice text. It does not mechanically block extra fields. Without schema enforcement, a single violation breaks downstream processing, so this instruction alone is insufficient to guarantee that only allowed field names appear.

  • ✓

    Define the extraction schema as a tool 'input_schema' and force tool use.

    Why this is correct

    When the schema is expressed as a tool 'input_schema' and tool use is forced, Claude must emit arguments that conform to that schema. Invented field names would violate the schema and are therefore avoided. This provides structural enforcement that examples and temperature settings cannot achieve, directly preventing hallucinated keys in the extraction output.

About these practice questions

This CCAR-F question is part of Courseiva's 271-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Anthropic exam blueprint

This CCAR-F practice question is part of Courseiva's free Anthropic certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CCAR-F exam.