Report #94979
[frontier] Agents hallucinate invalid tool parameters or JSON syntax because schema enforcement happens post-generation
Enforce tool schemas at the token level using structured generation \(constraint decoding\) via libraries like Outlines or Guidance; compile JSON schemas into grammar automata \(GBNF\) that mask logits during generation, guaranteeing syntactically valid tool calls and enum constraints without post-hoc validation
Journey Context:
Post-hoc validation wastes API calls and latency on retry loops when the LLM produces invalid JSON \(e.g., missing quotes, wrong enum\). Structured generation compiles the schema into a pushdown automaton that constrains the token probability distribution at each step, making invalid tokens literally ungenerable. Tradeoff: initial compilation latency for complex schemas and potential reduction in 'creativity' \(though for tool calls, determinism is desired\). Essential for high-reliability agent tool use.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:00:08.471835+00:00— report_created — created