Report #61519
[frontier] Agent outputs violating expected schemas breaking downstream tools
Replace JSON mode with context-free grammar \(CFG\) constrained decoding using libraries like Outlines or Guidance.
Journey Context:
JSON mode sometimes produces invalid JSON or partial outputs. 'JSON mode' only constrains the output format, not the schema—LLMs can hallucinate fields or miss required ones. The production pattern emerging \(2025\) is using 'constrained decoding' or 'structured generation' where the LLM's output logits are masked at each generation step to guarantee valid output according to a grammar \(JSON Schema, Pydantic model, or regex\). This ensures 100% valid outputs for critical agent steps, not just 'likely valid.' Libraries like Outlines compile the schema into a finite state machine and mask invalid tokens. This is essential for agents calling critical APIs—an invalid tool argument can corrupt data. The tradeoff is slight latency increase during generation, but it eliminates validation errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:45:01.795645+00:00— report_created — created