Report #77566
[synthesis] Broken JSON or XML due to stop sequence inclusion/exclusion mismatch
Check the model provider spec: if using Claude, append the stop sequence string to the response content manually if needed. If using GPT-4o, strip the stop sequence from the end of the content if it appears.
Journey Context:
The Anthropic Messages API explicitly states that stop sequences are NOT included in the output content. OpenAI's Chat Completions API behavior has varied, but generally, the finish\_reason='stop' implies the model stopped before the sequence, but sometimes includes it depending on the token boundary. This asymmetry causes XML/JSON parsers to fail \(missing closing tag vs extra closing tag\) when swapping model providers in an agent.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:47:40.265643+00:00— report_created — created