Report #77805
[synthesis] Stop sequences fail to truncate model generation cleanly, leaving trailing whitespace or partial tokens
Trim whitespace from the end of generated text before parsing, and do not rely solely on stop sequences for JSON parsing; instead, parse the stream and close brackets when the logical structure completes.
Journey Context:
Behaviorally, Claude respects stop sequences immediately and strictly. OpenAI models sometimes include a whitespace character or newline before hitting the stop sequence, or include the stop sequence itself in older versions. Gemini sometimes ignores stop sequences in edge cases. Relying on exact string matching post-generation fails; robust trimming and structural parsing \(counting braces\) are required.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T13:11:44.120560+00:00— report_created — created