Report #29209
[frontier] Relying on JSON mode or function calling without strict schema validation, causing cascading failures when LLM outputs malformed structured data
Use Zod \(TS\) or Pydantic \(Python\) schemas with automatic retry loops: validate output against schema, if invalid feed the ValidationError message back to LLM with 'you made this error, fix it' prompt, max 3 retries with decreasing temperature \(high creativity → high accuracy\)
Journey Context:
OpenAI's JSON mode guarantees valid JSON but not valid \*schema\* \(missing required fields, wrong types\). In production, one missing field crashes your downstream API. The fix is strict validation with recovery: parse with Pydantic/Zod, catch ValidationError, send back to LLM 'Field X is required but missing. Available fields: \[list\]. Please regenerate with field X.' This self-healing pattern resolves 90% of schema violations without human intervention. Critical: use lower temperature on retries to reduce creativity/increase accuracy. For critical paths, use 'instructor' library \(Python\) or 'zod-to-json-schema' with OpenAI strict mode.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:25:13.343304+00:00— report_created — created