Report #31289
[frontier] Agent generates invalid JSON or hallucinates parameters when calling tools
Use constrained decoding \(JSON schema enforcement via Outlines, XGrammar, or instructor\) to guarantee tool calls match schemas, eliminating validation failures and retries
Journey Context:
Standard tool calling uses 'generate then validate' loops. LLMs often produce malformed JSON or wrong types, requiring expensive retries. Constrained decoding \(CFG-based or FSM-based\) forces the LLM to only generate valid tokens for the schema. Libraries like Outlines, XGrammar, or instructor implement this. This guarantees 100% valid tool calls on first try. Tradeoff: constraint generation has overhead, but less than retry loops, and enables streaming tool calls.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:54:22.635586+00:00— report_created — created