Databricks Certified Generative AI Engineer Associate free question 2 / 10 · Domain 1: Design Applications
An application asks a Foundation Model APIs chat model to return a summary and a rating (1 to 5) for each product review as JSON. To keep the summary within the screen layout, the developer writes maxLength: 100 on the summary field of the JSON schema and passes it in response_format (type json_schema, strict true). Which statement about the JSON that comes back matches the documentation?
- maxLength is not enforced, so a summary longer than 100 characters can still be returned
- Generation stops when it reaches 100 characters, so the summary value comes back cut off at 100 characters
- When the summary runs past 100 characters, generation is redone until it fits the schema, and only then is the result returned
- A schema that contains a length constraint is rejected, and the request itself returns an error
Show the answer and explanation
Answer: A
Why this is correct
The Limitations section of the structured outputs page says that Foundation Model APIs does not enforce length or size constraints for objects and arrays, and that this includes keywords like maxProperties, minProperties and maxLength. Writing maxLength: 100 in the schema therefore does not bind the model's output to that length, and a summary longer than 100 characters can be returned. Schema validation works toward matching the shape (keys and types); quantity rules such as a character count have to be handled by the prompt instructions or by processing after the response.
Why the other options are wrong
"Generation stops when it reaches 100 characters, so the summary value comes back cut off at 100 characters" … Foundation Model APIs is documented as not enforcing length or size constraints for objects and arrays. Nothing says generation is stopped at 100 characters, so an over-long summary comes back as it is.
"A schema that contains a length constraint is rejected, and the request itself returns an error" … The length keywords are not on the list of unsupported keys (pattern, anyOf and so on). Because the Limitations section says they are simply not enforced, the request goes through and the response comes back with the constraint having no effect.
"When the summary runs past 100 characters, generation is redone until it fits the schema, and only then is the result returned" … Because the length constraint is not enforced, there is no step that detects an over-long response and regenerates it. If the app does not check the length itself, a summary that overflows the screen is displayed as is.
Key point
Quantity rules hold up better when they are handled in two places: write "within 100 characters" in the prompt, and have the application check the length and either truncate or ask again. The same reasoning applies to upper and lower limits on the number of array items; writing them in the schema alone does not guarantee them.