Report #82767
[gotcha] Complex JSON Schema in tool inputSchema causes models to generate invalid parameters
Flatten inputSchema to simple objects with primitive string/number/boolean fields. Avoid oneOf, allOf, anyOf, nested objects, and pattern properties in schemas exposed to the LLM. Move validation logic into the tool implementation and return clear error messages via isError when validation fails.
Journey Context:
Developers naturally want precise schemas: using oneOf for polymorphic inputs, nested objects for structured data, allOf for composition. But LLMs struggle to generate valid JSON conforming to complex schemas — they omit required fields from nested objects, pick the wrong oneOf branch, or produce syntactically invalid JSON. The complex schema also bloats the context \(a detailed schema can be 500\+ tokens per tool\). The counter-intuitive insight is that simpler schemas with server-side validation outperform complex schemas with client-side \(model-side\) validation. The model generates valid params more reliably, and the tool's error message is more helpful than a schema violation the model can't debug.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:30:38.065463+00:00— report_created — created