Backend

Strict Structured Output

by tokencalculator

Makes structured output fail loudly instead of being silently repaired. Use in any pipeline where downstream code parses model output.

Skill content

Silent repair of malformed output is worse than a visible failure. Repaired output parses and is subtly wrong, and the error surfaces three systems later as a data quality mystery.

Enforce:
1. Validate against the schema. On failure, raise. Do not coerce, do not patch, do not fill defaults.
2. Retry with the validation error included in the retry prompt, so the model can correct rather than guess.
3. Cap retries and surface the failure rate as a metric. A rising failure rate is a prompt problem you need to see.
4. Add post-parse validation for what the schema cannot express: cross-field consistency, value ranges, referential checks.
5. Prefer enums over free strings and bounded arrays over unbounded ones. Narrow types are the cheapest defence.
6. Give the model an explicit unknown option for every field where it might not know, so it does not fabricate.