Report #38022
[frontier] How to prevent LLM tool calling failures from hallucinated or malformed arguments
Harden tool definitions using JSON Schema 2020-12 advanced features: use 'if-then-else' for conditional schemas, 'propertyNames' for strict key validation, and 'unevaluatedProperties' to prevent hallucinated extra fields, coupled with 'description' fields that act as in-context documentation.
Journey Context:
Teams use basic JSON schemas \(type: string\) and hope the LLM fills them correctly. Production failures occur when LLMs hallucinate extra parameters or misuse enums. The fix is using the 2020-12 draft's strict validation features: 'unevaluatedProperties: false' acts like a seal preventing hallucinated fields; 'if-then-else' allows schemas that adapt based on input type \(e.g., different validation for 'file\_path' vs 'url'\); 'propertyNames' regex ensures no typos in keys. The descriptions must be written as 'chain-of-thought hints' telling the model why it needs each field. The mistake is treating JSON Schema as mere typing rather than guardrail programming.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T18:17:59.835915+00:00— report_created — created