Report #29876
[counterintuitive] Model fails to adhere to strict output length constraints or complex nested JSON schemas
Use structured output features \(JSON mode/grammar constraints\) for schema adherence, and use post-processing scripts for length/count constraints rather than relying on the prompt.
Journey Context:
LLMs do not possess an internal counter or a rigid state machine for output formatting. Asking for exactly N words or a highly nested JSON without schema enforcement relies on the model's ability to predict the end token at precisely the right probabilistic step, which is fundamentally unreliable. Grammar-constrained decoding alters the logit sampling space, making schema adherence an architectural guarantee rather than a prompt request.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:32:10.060696+00:00— report_created — created