Skills
Two-Step Reasoning Pattern for Guaranteed Structured LLM Output: Free-Form Analysis First, Then Constrained Decoding — Improves Accuracy on Complex Tasks
The emerging best practice for structured output from LLMs splits the work into two calls: the first generates unconstrained free-form analysis and reasoning, the second (much shorter) uses constrained decoding to convert the analysis into guaranteed-valid JSON. This avoids the quality degradation that occurs when reasoning and format compliance compete in a single call. Combined with hybrid routing — sending simple schemas to cheap models and complex schemas to reliable ones — this cuts structured output costs by 40-60% without sacrificing reliability. Without any enforcement, LLM JSON responses fail parsing 8-15% of the time; with native structured output, that drops below 0.1%.
Source
↳ Follow the thread