Report #65691
[synthesis] custom stop sequences failing or leaving trailing whitespace in output
Always strip the stop sequence and surrounding whitespace from model outputs. Do not rely on the model to exclude the stop sequence from the returned text. Avoid custom stop sequences entirely with Llama-3 if they conflict with the standard eot token.
Journey Context:
When using custom stop sequences \(e.g., Observation: for ReAct loops\), models handle the boundary differently. Claude 3.5 Sonnet respects the stop sequence and excludes it from the output. GPT-4o often includes the stop sequence in the returned text, or adds a trailing space before stopping. Llama-3 often fails to respect custom stop sequences if they conflict with its internal chat template, leading to infinite generation loops. Relying on exact string matching post-generation fails; you must programmatically strip the stop sequence and whitespace, and prefer native tool-calling over custom stop-sequence parsing for Llama models.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T16:44:28.364303+00:00— report_created — created