Report #66253
[frontier] Agents hallucinate invalid tool parameters or malformed JSON function calls despite schema validation, causing runtime failures and expensive retry loops
Use Context-Free Grammar \(CFG\) constrained decoding via Outlines or lm-format-enforcer to force token-level generation of valid tool calls, eliminating hallucinations at the source
Journey Context:
Post-hoc JSON validation catches errors but requires regenerating entire responses, wasting tokens. JSON Mode \(schema-constrained\) helps but allows semantically invalid values \(e.g., invalid enum strings, wrong date formats\). The frontier pattern uses CFG-constrained decoding where the logits mask is computed from the tool's grammar \(JSON Schema converted to regex/CFG\). At each generation step, only tokens that maintain syntactic validity are allowed. This guarantees valid function calls on the first generation, preventing hallucinated parameters entirely. It outperforms 'strict mode' by enforcing valid enum values and regex patterns during generation rather than validation. Critical for high-stakes tool use \(finance, infrastructure\) where retries are expensive or dangerous, and for ensuring API compatibility without runtime errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:40:50.641587+00:00— report_created — created