A parks department builds a small service that turns shelter-reservation requests into a JSON record for its booking system. The prompt asks for JSON only, but roughly one response in six begins with a line such as 'Here is the JSON you requested:' before the object, which breaks the downstream parser. Which technique most directly guarantees the response begins as JSON?
Select an answer to reveal the explanation.
Short Explanation
This is the difference between asking someone not to clear their throat and starting the sentence for them. Prefill an assistant turn with the opening brace and a preamble has nowhere to go.
Full Explanation
Making a response begin a particular way is a structural problem, and structural problems want structural remedies rather than stronger requests. Any instruction to omit a preamble is still an instruction the model can miss on some fraction of samples, which is precisely the one-in-six intermittent failure the parks service is reporting.
The Messages API accepts a trailing assistant message and continues generation from its content, so ending the array with an assistant turn containing the opening brace means the response is already inside the JSON object. No position remains where a conversational lead-in could appear. The prefill is not echoed back, so the service concatenates the brace it supplied with the returned text before parsing.
Repeating a prohibition three times is still a request, and repetition never converts guidance into a guarantee; switching to YAML changes the serialization without changing the model's tendency to open with a sentence, and it loosens parsing rather than tightening it; raising max_tokens addresses truncation at the end of a response and has no bearing on what gets emitted first.
Exam caveat: prefill constrains where a response starts, not whether it is valid, and it is unavailable in some modes such as extended thinking, so the parser still needs error handling. Operational check: log a hundred reservation records, confirm every one parses after the brace is prepended, and add a stop sequence on the closing brace to trim anything the model appends afterward.