Report #1767
[gotcha] Agent hallucinates wrong types or invents values for deeply nested tool parameters
Flatten tool schemas wherever possible. Replace nested objects with dot-notation top-level parameters \(e.g., 'config.options.flags' becomes a top-level 'config\_options\_flags' parameter\). Avoid oneOf/anyOf/allOf in schemas — use separate tools instead. Put concrete examples in the description field, not just in the schema. Keep required fields to a minimum; make truly optional fields optional.
Journey Context:
LLMs generate tokens that approximately match the JSON schema — they do not execute schema validation. A tool parameter defined as a nested object with required inner fields will frequently receive wrong types, missing inner fields, or hallucinated values at depth. The model 'sees' the schema but its attention on deeply nested constraints is weak. Flat schemas work because each parameter gets individual attention during generation. oneOf/anyOf are particularly disastrous — the model often mixes properties from multiple variants. The JSON Schema spec supports rich validation, but for LLM tool definitions, simpler is always better. This is counter-intuitive for developers coming from REST API design where nested schemas are idiomatic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T07:31:52.122839+00:00— report_created — created