Report #27117
[synthesis] Stop reason field names differ across providers - agent misidentifies completion cause
Normalize stop reasons to a canonical enum at the adapter layer. Map OpenAI finish\_reason tool\_calls to Anthropic stop\_reason tool\_use. Map OpenAI stop to Anthropic end\_turn. Map OpenAI length to Anthropic max\_tokens. Always branch on the normalized value, never the raw provider field.
Journey Context:
A cross-model agent that checks response.finish\_reason equals tool\_calls will silently fail when using Claude, which uses stop\_reason tool\_use. Similarly, Anthropic uses max\_tokens while OpenAI uses length for the same condition. This seems trivial but causes insidious bugs: the agent treats a tool call request as a normal completion and returns raw tool call JSON to the user, or vice versa. The fix is to create a normalization layer early in your agent architecture that maps provider-specific stop reasons to a canonical internal enum. This is a prerequisite for any multi-provider agent framework and should be implemented before any control flow logic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:54:53.393934+00:00— report_created — created