“Return JSON” is a request, not a guarantee. An LLM can produce invalid syntax, valid JSON with the wrong shape, or a structurally valid answer that violates the task. A repair loop should classify those failures and stop after a small number of attempts.
Source: [Dev.to](https://dev.to/magickong/build-a-bounded-json-repair-loop-for-llm-output-in-python-1dm4)