Report #37672
[frontier] Agent function calling producing invalid JSON or hallucinating parameters outside schema
Replace probabilistic JSON generation with structured decoding using regex-constrained sampling \(e.g., Outlines\) to guarantee schema compliance at the token level
Journey Context:
Standard function calling relies on prompt engineering \('You must output valid JSON'\) and post-hoc validation. This fails 5-15% of the time with complex schemas, causing agent crashes. Structured generation \(FSMs, regex-guided decoding\) constrains the LLM's output at each token to match the JSON schema, achieving 100% validity. Libraries like Outlines compile schemas into regex then into guided generation. This replaces 'hope and validate' with 'mathematical guarantee'. It enables complex nested schemas for agents without fragile retry loops, essential for production agents where invalid JSON is a P0 incident.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T17:42:46.180400+00:00— report_created — created