A school district's transportation office gets a structured output with five levels of nesting — route, then stops, then per-stop riders, then per-rider accommodations, then contact records. The model fills the top two levels reliably but the deeper objects come back with fields at inconsistent depths and occasional empty containers. Which change most likely restores reliable output?
Select an answer to reveal the explanation.
Short Explanation
Five levels of nesting asks the model to hold five open brackets in its head while writing. Flatten into shallow records keyed by identifier and each shape becomes unmistakable.
Full Explanation
Structural depth is a load the model carries while generating, and the failure pattern here names it precisely: the top two levels come back reliably and the deeper objects wobble. Fields landing at the wrong depth and empty containers appearing are characteristic of tracking too many open contexts at once, not of running out of room to finish.
Flattening toward a few shallow record types, routes and stops and riders and their accommodations and contacts, each keyed by identifier, preserves every relationship in the data while making each individual object short enough that its shape is unambiguous. It also localizes failure, since a malformed rider record no longer implicates an entire route tree and a validation error points at one small object.
Raising max_tokens addresses truncation, but the reported defect is misplaced fields rather than a response cut short; adding a full five-level example lengthens the prompt substantially while leaving the structural burden exactly where it was; and requesting the structure as a formatted string hands the parsing problem back to the transportation office and gives up schema validation entirely.
Exam caveat: flattening moves work rather than erasing it, because the office now has to join records by identifier and check referential integrity, so a rider pointing at a stop that does not exist becomes the new failure mode. Operational check: emit the flattened records for a full route, verify every identifier reference resolves, and confirm the depth defects disappear across a sample of runs.