A schema bug, a retry that couldn't help, and a small design rule I'm keeping.
The error
One day a StructFlow job β the structured-extraction service on my document-processing API β failed with an error I had never seen:
Schemas contains too many parameters with union types (27 parameters with type arrays or anyOf). This causes exponential compilation cost. Reduce the number of nullable or union-typed parameters (limit: 16 parameters with unions).
Enter fullscreen mode
Exit fullscreen mode
My first guess was length β the schema must be too big. Wrong. The input wasn't unusually long. More to the point, I had never written this schema at all: on this API, the output schema is derived from each user's example_output β a JSON example of the shape they want. That detail matters. A fixed internal schema either fits under a limit forever or fails on day one; my services built that way had run quietly for months.β¦