CCAR-F domain - 20% of the exam

Prompt Engineering & Structured Output

Prompt Engineering & Structured Output is 20% of the CCAR-F exam. These are the objectives it covers, each with practice questions, with every answer explained.

The domain in numbers

67
Practice questions
6
Objectives
44
Medium
23
Hard

Where people go wrong

  • Treating schema validation as proof of correct values

    The wrong answers credit a passing schema check with more than it checks. Validation confirms that a value has the declared type, shape and presence, so an enum label, a number in range or a currency code of the right length passes whether or not it is correct. A pre-tax subtotal written to the total field validates exactly as the true total does. Meaning is verified by a separate check, such as reconciling line items, tax and total.

    See it in a sample question
  • Expecting retries to recover information the source lacks

    The wrong answers keep demanding a value the document does not hold: more retries, repeated samples, a firmer instruction or a required field that permits no null. A smudged purchase order number or a cropped header cannot be recovered by asking again, so the model supplies a plausible invented value to satisfy the schema. Retry feedback repairs how a present value is reported. For an absent one, make the field nullable with a reason code and route those records to a person to check.

    See it in a sample question
  • Putting a merge-blocking check on the Message Batches API

    The wrong answers move a check that gates a merge onto the Message Batches API to save cost or allow a longer pass. Batch requests are processed asynchronously within a window of up to 24 hours, whatever the batch size, so a gate that must hold a merge open cannot depend on the result arriving in time. Spend the discount on work read later, such as a nightly repository-wide scan, and keep the check that blocks merging synchronous.

    See it in a sample question
  • Handling batch results by position or as one unit

    The wrong answers treat a batch as an ordered, all-or-nothing unit. Results are not guaranteed to return in submission order, so pairing the nth result with the nth document attaches totals to the wrong invoice; the custom_id set on each request is the correlation key. Each request also succeeds or fails alone, so only the errored custom_ids are resubmitted in a new batch while the succeeded results are kept and used.

    See it in a sample question

Objectives in this domain

Sample questions from this domain

Free samplePrompt Engineering & Structured Outputmedium

The Merge Gate team makes their CI review job return structured findings, each with a severity field restricted to the values blocker, major or minor by the schema fragment below, and the pipeline rejects any response that fails validation. Across one month every response validates cleanly and no run is rejected. A triage review then finds that 30 percent of the findings labelled blocker are formatting preferences that no engineer would hold a merge for. What does schema validation guarantee about those findings?

"severity": {
  "type": "string",
  "enum": ["blocker", "major", "minor"]
},
"file":    { "type": "string" },
"line":    { "type": "integer" },
"message": { "type": "string", "minLength": 20 }
  • AIt guarantees that the labels were applied consistently within a response, because a single validated payload cannot mix two different readings of the criteria across its own entries.
  • BIt guarantees only that the severity value is one of the three permitted labels, and says nothing about whether the finding satisfies the team's written definition of a blocker. Correct
  • CIt guarantees that each finding came from the diff rather than the wider repository, since the file and line fields have to resolve to positions the pull request actually touched.
  • DIt guarantees that a re-run against the same diff yields the same severity for the same defect, because a constrained field removes the variation that produces label drift.
Schema validation constrains the shape and permitted values of an output, never the judgement that selected a particular value. Validation is a syntactic check applied after generation. The enum rejects any severity outside the three listed strings, so a payload carrying blocker is accepted whether that label was assigned to a race condition or to an indentation preference. The mislabelled findings are semantic errors inside a structurally valid response, and the only things that reach them are explicit criteria in the prompt defining what earns each band, plus a check that inspects the finding text against those criteria before the comment is posted.

Why A is wrong: Consistency within one response sounds like something structure would buy, but validation inspects each field independently; nothing compares one finding's severity reasoning against another's in the same payload.

Why B is correct: Correct. An enum is a constraint on the set of allowed strings. It admits the label blocker regardless of what the model applied it to, so semantic misclassification passes validation untouched.

Why C is wrong: The schema requires a string and an integer in those fields, not a position inside the changed lines; resolving a line to the diff would need a separate check the pipeline is not running.

Why D is wrong: Constraining the output alphabet narrows what can be emitted, not which of the permitted values the model chooses, so a re-run can move the same defect between bands and still validate.

Free samplePrompt Engineering & Structured Outputmedium

A document intelligence team runs an invoice extraction pipeline that reads scanned supplier invoices and emits fields against a JSON schema in which purchase_order_number is nullable. Across a sample of 2,000 scanned pages, where the purchase order number is smudged or cropped the service returns a well-formed but invented number in 6.4 percent of documents, and downstream ledger matching then fails without raising an error. The system prompt already states that unreadable fields must be returned as null. Which change most effectively addresses the logged behaviour?

  • AAdd few-shot examples that pair a page whose purchase order number is obscured with the intended output holding null for that field, so the ambiguous case is demonstrated rather than described. Correct
  • BRestate the instruction about unreadable fields at both the start and the end of the system prompt and mark it as a strict processing rule.
  • CMake purchase_order_number a required string in the schema so validation rejects any extraction that omits it and the document can be routed for reprocessing.
  • DRetry the extraction up to three times whenever the purchase order number reads as absent, and accept the first value on which two attempts agree.
Demonstrating the intended output for an unreadable or missing field is more reliable than describing that behaviour in an instruction. A stated rule must be generalised by the model to a document class it has never seen, whereas a demonstration fixes the mapping from a concrete evidence state to a concrete output. Showing the null case also removes the pull created when every example in the prompt carries a populated value, which is what makes invention the likelier completion on a degraded page.

Why A is correct: Correct because the failure is confined to a specific evidence state, an unreadable field, and a worked example fixes the mapping from that state to the intended output token instead of asking the model to derive it from a general rule.

Why B is wrong: Tempting because instruction placement and emphasis do measurably affect adherence, and repeating a rule is the cheapest thing to try. It is wrong here because the rule has already been stated and is being violated on a case the model has never been shown, so compliance stays probabilistic on exactly the documents that fail.

Why C is wrong: Tempting because schema validation is deterministic and a rejected document is visible rather than silent. It is wrong because removing the null option forces the model to produce a value for a field it cannot read, and validation cannot distinguish an invented identifier from a correctly read one.

Why D is wrong: Tempting because sampling several times and taking agreement is a real technique for unstable outputs. It is wrong because no retry recovers characters the page does not carry, and repeated samples of a plausible invention are quite likely to agree with each other.

Free samplePrompt Engineering & Structured Outputmedium

A CI code review job built on Claude Code takes eleven minutes against a five minute pre-merge budget, and merges are queueing behind it. The job currently reviews every file in the repository that the changed files import, across nine finding categories. An engineer proposes moving the work to the Message Batches API, citing the lower cost per request and the freedom to run a longer pass. What should the architect do?

  • AAdopt the batches route as proposed and post its findings whenever they arrive, accepting that some pull requests will have merged before their review lands on the thread.
  • BKeep the current prompt and raise the job timeout to fifteen minutes, so that the review completes and reviewers are shown the full set of findings before the merge proceeds.
  • CKeep the current prompt and cache the repository checkout between runs, on the basis that the checkout is the part of the job most likely to dominate the elapsed time.
  • DKeep the review synchronous and cut its scope with explicit criteria, restricting it to the changed files and a named set of finding categories, since the batches route is asynchronous and cannot gate a merge. Correct
A blocking pre-merge review must stay synchronous; meet a build-time budget by narrowing review scope and categories rather than by batching. The Message Batches API is asynchronous and returns results within a window of up to 24 hours, so it suits offline or bulk work and cannot supply a verdict that a merge waits on. With the route fixed as synchronous, the remaining levers are the size of the reviewed surface and the number of categories, and tightening both cuts the model work in the job while narrowing what qualifies as a finding.

Why A is wrong: Tempting because the cost saving is real and the reviews do eventually appear, but the Message Batches API processes asynchronously within a window of up to 24 hours, so the job stops being a merge gate and defects reach the default branch unreviewed.

Why B is wrong: Tempting because it makes the job pass reliably and preserves coverage, but it concedes the budget the team set rather than meeting it and lengthens the merge queue that prompted the complaint.

Why C is wrong: Tempting because caching is standard CI practice and does trim setup, but the elapsed time here is dominated by model calls over a transitively expanded file set, so the saving is small against a six minute overrun.

Why D is correct: Correct because a pre-merge gate needs a result within the build, which rules out an asynchronous route, and narrowing the reviewed surface and the category list is the lever that reduces elapsed time while also raising precision.

Free samplePrompt Engineering & Structured Outputmedium

The Ledgerline document platform extracts supplier name, invoice number, currency and total from scanned invoices, then validates each extraction against a JSON schema before writing it to the finance ledger. Nightly volume of 8,000 invoices is submitted through the Message Batches API, one request per invoice, and the pipeline reads the results file in the order the lines arrive and zips it against the submitted list by position. Finance reports that roughly one ledger row in nine carries the totals of a different invoice. What explains this outcome?

  • ASchema validation ran before the results were paired with their source documents, so a mismatched total passed the numeric type check and was written to the ledger unflagged.
  • BThe batch exceeded the size at which requests are split across shards, and each shard returns a separate results file that the pipeline concatenated in the wrong sequence.
  • CResults from a batch are not guaranteed to come back in submission order, so positional zipping is unsafe and each result must be matched to its source document through the custom_id supplied on the request. Correct
  • DRequests that took longer than the median to process were retried internally and appended at the end of the file, which shifted the position of every result after the first slow invoice.
Batch results arrive in no guaranteed order, so each result must be correlated to its source through the caller-supplied custom_id. The Message Batches API processes requests independently and returns results without any ordering promise relative to submission. The custom_id set by the caller on each request is echoed on the corresponding result, and it is the reliable key for reattaching an extraction to the document it came from. Positional pairing works only by accident and fails as soon as any request finishes out of sequence.

Why A is wrong: Tempting because validation ordering does matter for catching bad values, but schema validation was never the pairing mechanism here, and running it later would still leave every row attached to the wrong invoice.

Why B is wrong: Plausible because large workloads often shard in other systems, but a batch returns one results set for the caller and there is no shard concatenation step the pipeline could have got wrong.

Why C is correct: Correct: ordering is explicitly not guaranteed for batch results, and the caller-supplied custom_id is the field provided for correlating each result back to its originating request.

Why D is wrong: Tempting because it offers a mechanism for reordering, but no such internal retry-and-append behaviour is defined, and inventing one distracts from the real point that order is simply not promised.

Other domains in this exam

See also the CCAR-F cert hub, the study guide, and the cheat sheet.

Examworthy is not affiliated with or endorsed by Anthropic. Original, blueprint-aligned practice material only.