Report #73793
[synthesis] Model includes the stop sequence string or an extra space before stopping, breaking parsers
Trim the last few characters of the model's output or use regex/fuzzy matching for stop boundaries. For Claude, explicitly define the stop sequence in the API and strip any trailing whitespace or partial matches of the stop sequence.
Journey Context:
When using stop sequences \(e.g., '\\nObservation:' for ReAct agents\), models exhibit subtle parsing differences. GPT-4o generally stops exactly before the sequence. Claude 3.5 Sonnet sometimes includes a partial match of the stop sequence \(e.g., '\\nObservatio'\) or an extra newline before stopping. Llama 3 often generates right through the stop sequence if it's highly confident. The cross-model insight is that tokenization boundaries make exact stop sequence matching unreliable; parsers must be resilient to partial or offset stop sequence generation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:27:31.846695+00:00— report_created — created