Report #48263
[architecture] LLM function calling produces malformed JSON that breaks downstream parsers
Enable 'strict: true' mode in OpenAI function calling \(or equivalent constrained decoding in vLLM/Guidance\) to force the model to follow the JSON Schema exactly; additionally, validate outputs using ajv \(JavaScript\) or jsonschema \(Python\) with 'strictTypes: true' before passing to the next agent, rejecting any that fail with a 422 error to trigger a retry loop.
Journey Context:
Even with GPT-4, function calling occasionally produces JSON with missing required fields, wrong types \(strings instead of numbers\), or extra properties that downstream agents don't expect. Standard mode allows the model to 'hallucinate' schema fields. Strict mode \(added late 2023\) constrains the token generator to only valid tokens for the schema, eliminating syntax errors. However, semantic errors \(wrong enum values\) still occur, requiring secondary validation. People often trust LLM outputs implicitly, leading to 'undefined is not a function' crashes three agents downstream.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T11:29:06.329201+00:00— report_created — created