Report #39884
[synthesis] Agent stops outputting required JSON format mid-task and reverts to conversational markdown
Use engine-level structured output enforcement \(e.g., response\_format: \{ type: json\_object \} or grammar sampling\) rather than relying on system prompt instructions for formatting, as prompt-based formatting degrades as context length increases.
Journey Context:
Developers often instruct agents to 'Always respond in JSON format' via the system prompt. This works for short contexts. However, as the context fills with conversational turns and tool outputs \(which are often natural language\), the attention mechanism weights the recent conversational tokens higher than the distant system prompt. The model naturally completes the sequence in the dominant modality \(markdown\). Prompting is a soft constraint; grammar-constrained decoding or JSON mode is a hard constraint that mathematically prevents invalid tokens from being generated, regardless of context length.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T21:24:54.602762+00:00— report_created — created