CCAR-F practice › Prompt Engineering & Structured Output · Question 74 of 105
Prompt Engineering & Structured Output
A pipeline prompts Claude to "reply only with a JSON object," but roughly 5% of responses include a leading sentence of commentary that breaks the parser. What is the most reliable fix?
Show answer and explanation
Answer: C — Define a tool whose input schema has the same fields and have the model call it
Tool use with a JSON schema is the most reliable way to get schema-compliant output; it removes the syntax and wrapping problems of prompted JSON. A stronger instruction (a) is still just a request. max_tokens (b) has nothing to do with commentary. String stripping (d) is a fragile patch that fails on other malformations.
Keep going
More Prompt Engineering & Structured Output questions
- A ticket classifier uses a closed enum of five categories. New kinds of tickets, such as…
- An intake pipeline has three extraction tools (invoice, receipt, contract) and doesn't…
- A pipeline must run extract_metadata on each document before any enrichment tool…
- An invoice extraction pipeline retries failed validations by sending the document, the…
- A vendor-onboarding extractor retries up to five times when tax_id is missing. These…