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.