Report #36503
[synthesis] Agent misinterprets stop\_reason across providers - 'end\_turn' vs 'stop' vs 'STOP' have different semantics
Normalize stop reasons at the provider adapter layer with semantic-aware mapping, not just string aliasing. Map: Anthropic \`end\_turn\` → natural completion, \`max\_tokens\` → truncation; OpenAI \`stop\` → natural completion OR stop sequence hit \(check if you defined stop sequences\), \`length\` → truncation; Gemini \`STOP\` → natural completion, \`MAX\_TOKENS\` → truncation. Treat any unmapped stop reason as an error requiring investigation.
Journey Context:
The same concept — model finished generating — is encoded differently across providers, but the dangerous part is the partial semantic overlaps. OpenAI's \`stop\` can mean natural completion OR that the model hit a custom stop sequence you defined, which is NOT the same as natural completion \(the model may have wanted to continue\). Anthropic's \`end\_turn\` unambiguously means the model chose to stop; \`stop\_sequence\` means it hit a defined stop sequence. An agent that treats all 'stop' signals as 'natural completion' will miss truncation events on OpenAI \(where \`length\` is the truncation signal\) and misinterpret stop-sequence hits as natural completions. The synthesis: stop reason interpretation requires provider-specific semantic logic, not just string normalization. A naive mapping layer that aliases \`stop\` → \`end\_turn\` → \`STOP\` loses critical information about WHY the model stopped.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:44:29.710152+00:00— report_created — created