Report #73712
[frontier] Agent tool outputs parse inconsistently causing downstream JSON decode errors or schema mismatches
Use OpenAI's structured outputs with strict: true and Pydantic v2 models to enforce exact schema compliance at the token generation level, refusing malformed outputs
Journey Context:
Earlier approaches relied on JSON mode or regex parsing, allowing models to omit fields or hallucinate keys. This caused cascading failures when downstream tools expected exact schemas. OpenAI's structured outputs \(mid-2024, but the strict agent contract pattern emerged 2025\) uses constrained decoding—restricting token generation to only valid JSON schemas at the logits level. With strict: true, the API guarantees output matches the provided JSON Schema exactly, or returns a refusal error rather than malformed JSON. This transforms tool calling from 'best effort parsing' to 'compile-time guarantees', enabling safe composition of agent pipelines where Tool A's output feeds directly into Tool B's input without defensive validation code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:19:25.614293+00:00— report_created — created