Report #64500
[architecture] Malformed JSON from LLMs breaks downstream parsing with cryptic errors
Use Pydantic v2 \`model\_validate\_json\` with \`strict=True\`; on validation failure, capture the specific error message and feed it back to the LLM in a retry loop for self-healing validation
Journey Context:
LLMs often output valid-ish JSON with trailing commas, single quotes, or comments. Standard json.loads fails. Pydantic strict mode catches type coercion attempts \(e.g., '123' -> 123\). The retry loop with error context often fixes the issue automatically without human intervention. This is more robust than regex cleaning which can corrupt nested structures.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:45:00.018487+00:00— report_created — created