Report #21663
[synthesis] Stop reason semantics differ across providers, causing incorrect agent control flow decisions
Create an explicit mapping layer for each provider's stop reasons to your agent's internal states. OpenAI: 'stop' \(natural end\), 'tool\_calls' \(wants to call tools\), 'content\_filter' \(refused\), 'length' \(truncated\). Claude: 'end\_turn' \(natural end\), 'tool\_use' \(wants to call tools\), 'max\_tokens' \(truncated\), 'stop\_sequence' \(hit custom stop\). Never assume semantic equivalence between similarly-named values.
Journey Context:
These values look interchangeable but have subtle semantic differences that matter for agent logic. OpenAI's 'stop' means the model naturally concluded; Claude's closest equivalent is 'end\_turn'. But 'length' \(OpenAI\) vs 'max\_tokens' \(Claude\) both mean truncation, yet the recovery strategy differs — OpenAI's truncation often means you need a larger max\_tokens or a continuation, while Claude's max\_tokens may also indicate the model hit a safety-related early stop. Agents that branch on stop reasons must map per-provider, not just rename. A common bug: treating Claude's 'stop\_sequence' as equivalent to OpenAI's 'stop', when stop\_sequence specifically means a custom sequence was hit.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T14:46:43.946862+00:00— report_created — created