CCAR-F Prompt Engineering and Structured Output Practice Question
You maintain a production pipeline where Claude extracts line items from scanned invoices and must return them as strict JSON conforming to a supplied schema. Intermittent outputs include a short apology sentence before the JSON object, which breaks your downstream parser. Logs show the preamble appears only when the OCR text contains contradictory totals. Which change most reliably eliminates the preamble while preserving extraction quality?
⚠ Common exam trap
The trap here is assuming that lowering temperature or adding XML tags controls what the model says first, when only constraining the completion prefix directly prevents a conversational preamble.
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
✓
Add a prefilled assistant turn containing the opening brace '{' so the model must continue directly from that character.
The failure is a prefix problem: the model decides to narrate before emitting the object. Constraining the assistant turn to begin with the opening brace forces the very first generated token to be part of the JSON structure, so no preamble can precede it. This preserves extraction quality because the model still reasons internally about contradictory totals while writing fields.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Increase the max_tokens value so the model has room to emit the apology and the full JSON without truncation.
Why it's wrong here
Raising max_tokens changes only the length ceiling, not the model's tendency to insert conversational text. The apology is not caused by truncation; it appears because the model reacts to contradictory totals in the OCR. Giving it more room would let it produce longer preambles, worsening the parser failure rather than removing it.
- ✗
Wrap the OCR text in <invoice> tags and instruct the model to read them carefully before answering.
Why it's wrong here
Structural XML delimiters help the model separate instructions from data, but they do not constrain the start of the completion. The model can still choose to write a sentence after reading the tags. Since the observed trigger is contradictory totals, clearer input boundaries do not prevent the apology from being generated ahead of the JSON payload.
- ✗
Lower the temperature to 0 so the sampling becomes deterministic and the apology sentence disappears.
Why it's wrong here
Temperature 0 reduces randomness and improves reproducibility, but it does not forbid a high-probability conversational opener. If the model consistently prefers an apology before the object when totals conflict, greedy decoding will still emit it every time. Determinism makes the failure more predictable, not less present, so the parser still breaks.
- ✓
Add a prefilled assistant turn containing the opening brace '{' so the model must continue directly from that character.
Why this is correct
Prefilling the assistant turn with the opening brace constrains generation to continue from that exact character, so the model cannot emit an apology sentence before the JSON. This works because the completion is a continuation of the provided prefix, which is precisely the failure mode observed: the model wants to comment on contradictory totals before producing the object.
About these practice questions
One of 271 original CCAR-F practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
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.