Report #25002
[counterintuitive] JSON mode guarantees semantically valid tool calls
Use constrained decoding \(grammars\) or strict mode with explicit enum/type constraints, and always validate the semantic schema in code before execution.
Journey Context:
Developers enable JSON mode assuming the LLM will output perfectly usable tool inputs. JSON mode only guarantees that the output parses as valid JSON \(brackets and quotes match\). The model will happily output syntactically valid but semantically useless JSON, like passing a string where an integer is required, or inventing parameters that don't exist in the schema. Constrained decoding \(like llama.cpp grammars or OpenAI's strict function calling\) forces the model to only emit tokens valid against the specific JSON schema, preventing type mismatches and hallucinated keys.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T20:22:32.478427+00:00— report_created — created