Courseiva

CCDV-F Prompt and Context Engineering Practice Question

A developer is building a pipeline that uses Claude to convert free-text incident reports into a strict JSON object with fields severity, services, and summary. During testing, roughly 8 percent of outputs include a friendly preamble such as 'Sure, here is the JSON:' or wrap the object in markdown code fences, which breaks the downstream parser. The developer has already described the schema precisely in the prompt. What is the most reliable next step to eliminate the malformed outputs?

⚠ Common exam trap

The trap here is believing that a clearer schema description or a trailing 'respond only with JSON' instruction is enough, when the failure is about the model's first emitted tokens.

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 few-shot example showing the exact JSON output with no preamble, and pre-fill the assistant turn with an opening curly brace so Claude must continue the object.

Pre-filling the assistant turn with an opening curly brace forces the model to begin inside the object, making a preamble or code fence structurally impossible. Pairing that constraint with a few-shot example that shows the exact no-preamble form teaches the desired surface pattern and covers cases where the schema itself is ambiguous.

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 zero and add the sentence 'Respond only with JSON' to the end of the user message.

    Why it's wrong here

    Temperature zero reduces sampling variance but does not eliminate structural drift, because the model still chooses whether to emit a preamble. A trailing instruction is also the weakest position for a formatting rule and can be outweighed by the earlier descriptive schema, so malformed outputs can persist.

  • ✗

    Wrap the schema description in <json_schema> tags and instruct Claude to output only what matches the schema.

    Why it's wrong here

    Delimiting the schema improves clarity, but the developer already described the schema precisely and still saw an 8 percent failure rate. Tagging alone does not constrain the first emitted token, so the model can still preface the object or fence it, leaving the parser broken.

  • ✓

    Add a few-shot example showing the exact JSON output with no preamble, and pre-fill the assistant turn with an opening curly brace so Claude must continue the object.

    Why this is correct

    Few-shot examples teach the exact surface form, and pre-filling the assistant turn with an opening brace constrains the first tokens so a preamble or code fence cannot be emitted. Together they remove both observed failure modes at generation time, which is more reliable than post-processing or relying on instructions alone.

  • ✗

    Increase max_tokens so the model has room to finish the JSON object without truncation.

    Why it's wrong here

    Truncation would produce an incomplete object, but the observed failures are complete outputs with a preamble or code fence. Raising max_tokens does nothing to stop the model from emitting 'Sure, here is the JSON:' or wrapping the result in backticks, so it does not address the reported defect.

About these practice questions

One of 257 original CCDV-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 →

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 CCDV-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 CCDV-F exam.