Report #28753
[frontier] LLM keeps generating invalid JSON/tool arguments
Use constrained decoding \(outlines, llama.cpp grammar, or OpenAI structured outputs\) to enforce JSON Schema at sampling time, eliminating post-hoc validation loops.
Journey Context:
Post-hoc validation \(catching JSONDecodeError and retrying\) wastes tokens and adds latency. Constrained decoding \(CFG-based or FSM-based\) masks the logits to only valid tokens per the schema. Outlines and guidance libraries do this for local models; OpenAI's structured outputs API does it server-side. The constraint is you need the schema upfront and some engines limit nested depth, but you gain deterministic output and reduced token waste.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T02:39:30.646251+00:00— report_created — created