CCAR-F Prompt Engineering and Structured Output Practice Question
A developer is building a contract-analysis pipeline. The prompt instructs Claude to return JSON with fields 'party_a', 'party_b', and 'effective_date'. In testing, Claude sometimes wraps the JSON in a Markdown code fence or adds a trailing comment, causing json.loads to fail. Which approach best ensures the response can be parsed directly as JSON?
⚠ Common exam trap
The trap here is treating tool use as only for external actions, when it is also the strongest mechanism for constraining the model to emit a schema-conformant JSON object.
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
✓
Use a tool definition with a JSON schema for the contract fields and require the model to call that tool.
Tool use with a JSON schema is the most reliable way to force structured output. The API validates the model's arguments against the schema and returns them as structured data, so the developer receives fields that match party_a, party_b, and effective_date without Markdown. Prompt-level requests and temperature changes do not guarantee parseable JSON in the same way.
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 model's max_tokens so the full JSON object fits in one response.
Why it's wrong here
max_tokens controls length, not syntax. If the JSON is truncated, raising the limit could help, but the scenario describes fences and comments, not truncation. The model is producing complete but malformed-for-the-parser output. This parameter does not address the formatting problem at all.
- ✓
Use a tool definition with a JSON schema for the contract fields and require the model to call that tool.
Why this is correct
Defining a tool with an input schema constrains the model to emit arguments that match the schema, which the API returns as structured data. In this scenario, that guarantees the fields party_a, party_b, and effective_date are produced in a parseable form without Markdown fences or comments. Tool use is the most reliable way to enforce a JSON shape.
- ✗
Add 'Please do not use Markdown' to the end of the prompt.
Why it's wrong here
Negative instructions are weakly followed and do not structurally prevent fences. The model may still add formatting because the instruction is not enforced. In this scenario, the parser needs a guaranteed shape, not a polite request. This approach leaves the same failure mode possible, making it unreliable for production.
- ✗
Instruct Claude to wrap the JSON in triple backticks so it is easy to find.
Why it's wrong here
Triple backticks are Markdown syntax, not valid JSON. A parser like json.loads will reject the surrounding fences unless the developer strips them first. The scenario explicitly wants direct parsing, so adding fences increases post-processing work. This instruction would make the failure mode more common rather than less.
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 →
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.