Report #46654
[frontier] Agents hallucinate tool parameters or generate malformed JSON despite few-shot prompting
Use grammar-based constrained decoding \(Outlines, XGrammar, or vLLM guided decoding\) to enforce syntactic validity of tool calls at the token generation level
Journey Context:
Post-hoc validation of JSON is too late; the model has already committed to invalid tokens. Constrained decoding uses finite-state machines \(FSMs\) or context-free grammars \(CFGs\) derived from JSON Schema to mask the vocabulary, ensuring only tokens that maintain syntactic validity are generated. This shifts reliability from stochastic 'hope' to deterministic guarantees. For example, if a parameter must be an enum, the decoder only samples from those tokens. This is critical for autonomous agents where a malformed API call could have side effects.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:46:59.835095+00:00— report_created — created