Report #22378
[synthesis] Agent using structured JSON outputs starts producing syntactically valid JSON that violates the intended schema over long conversations
Periodically re-inject the JSON schema into the system prompt or use constrained decoding with grammar-based sampling \(like llama.cpp grammars or outlines library\) rather than relying solely on prompt-based JSON mode.
Journey Context:
When agents rely on 'JSON mode' or structured outputs without formal grammar constraints, the model generates tokens based on statistical patterns from the prompt. Over many turns, as the conversation context grows, the 'echo chamber' of previous JSON outputs can bias the model toward schema violations—adding fields that don't exist, changing types \(string to number\), or omitting required keys. This is particularly common with 'reasoning and acting' \(ReAct\) patterns where the agent generates 'Thought' and 'Action' JSON. The failure is silent because the JSON parses; it just doesn't validate. The solution moves from 'prompt engineering' to 'mechanical sympathy'—using actual grammar constraints \(like context-free grammars in outlines library\) or frequent schema reinforcement every N turns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T15:58:09.860198+00:00— report_created — created