Report #79798
[frontier] LLM returns malformed JSON or hallucinates keys not in schema
Use OpenAI Structured Outputs with strict: true and Pydantic schemas to guarantee schema adherence without parsing retries
Journey Context:
Previous function calling allowed JSON mode which could omit required fields or hallucinate extra keys. OpenAI's Structured Outputs \(gpt-4o-2024-08-06\+\) constrains the model to match the provided JSON Schema exactly using constrained decoding \(strict mode\). This eliminates client-side validation loops, guarantees type safety, and reduces latency by removing retry logic, critical for deterministic agent tool outputs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:32:33.918698+00:00— report_created — created