Report #57826
[cost\_intel] JSON mode and Structured Outputs retry loops exhaust token quota on validation failures
Enable strict mode with 'additionalProperties: false'; pre-validate schemas with Zod client-side; implement circuit breaker with max 2 retries then fallback to GPT-4o-mini for JSON repair parsing
Journey Context:
When structured output fails validation, naive implementations immediately retry with the same high-cost model, rebilling the full context window each time. For GPT-4 class models, three retries on 8k context burns 24k tokens with zero forward progress. OpenAI data shows strict mode reduces validation errors by 90% by pre-declaring exact schemas. Client-side Zod validation catches 50%\+ of errors for near-zero cost. Falling back to GPT-4o-mini for repair parsing cuts recovery costs by 10x while maintaining schema compliance through constrained generation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T03:32:59.040471+00:00— report_created — created