Claude Certified Architect – Foundations Practice Question 97: Prefill Migration JSON

Claude Certified Architect, Foundations · Test 10 · question 7 of 10

Prompt Engineering & Structured Outputeasy

A ticket-classification service forces JSON output by ending each request with an assistant message that contains only {, so that Claude continues the object. After the team upgrades to a Claude 4.6 or later model, every request fails with HTTP 400 invalid_request_error saying the model does not support assistant message prefill and that the conversation must end with a user message. What is the recommended fix?

Select one answer
Show answer and explanation

Answer:

  • D. Remove the prefill and use structured outputs with output_config.format (or explicit system prompt instructions) to get JSON in the required shape

D is correct. The API errors page states that Claude 4.6 and later models do not support prefilling assistant messages and that a request with a prefilled last assistant message returns a 400 invalid_request_error. It recommends using structured outputs on models that support them, system prompt instructions, or output_config.format instead. Structured outputs also constrain the response to a schema, which the prefill trick never guaranteed.

A is wrong because a 400 means the request itself is invalid, so retrying the same request fails the same way. B is wrong because temperature does not control how a response begins, and it is not a format control; it only changes sampling randomness. C is wrong because a trailing brace in the user turn is only a hint and does not guarantee valid JSON or the schema; it is a workaround, not the documented replacement.

Reference: Claude API errors

Practice Test 10 ›

Study guides for Claude Certified Architect, Foundations