Report #30579
[frontier] LLMs fail to generate valid JSON for tool calls when schemas are deeply nested or overly constrained
Flatten tool schemas and use Pydantic or Zod with anyOf or optional fields carefully. Prefer multiple simple tools over one complex tool, and leverage native structured output features rather than raw prompt engineering.
Journey Context:
Developers define massive JSON schemas for tools, expecting the LLM to fill out 20 fields perfectly. LLMs struggle with deeply nested objects and strict required fields, often hallucinating values or breaking JSON syntax. The fix is to decompose the tool into smaller, flatter actions. Additionally, using the API provider's native structured output parsing \(which constrains the grammar at the token level\) reduces JSON syntax errors to near zero, though it does not fix semantic hallucinations for optional fields.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:42:47.026814+00:00— report_created — created