Report #102770
[cost\_intel] Structured output retries burn 2-5x the expected tokens when the model emits malformed JSON or schema violations
Use provider-native constrained decoding \(JSON mode, \`response\_format\`, \`tools\`\) rather than parsing free text and re-prompting. Set strict schema validation on the client, limit retries to 2, and on failure fall back to a smaller/cheaper validation-and-repair model instead of the main model.
Journey Context:
Without constrained output, even capable models occasionally omit trailing braces, use wrong enum values, or hallucinate keys. Each retry resends the full conversation plus an error correction prompt, and pays for another output. For complex nested schemas the failure rate can exceed 10%, turning a cheap call into several. Native JSON mode and strict schemas dramatically reduce this because the tokenizer is constrained, not because the prompt is better. Repair with a smaller model is cheaper than retrying with the flagship model.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T05:26:23.661792+00:00— report_created — created