Report #24756
[synthesis] Agent loop fails to detect tool-call termination or enters infinite loop across providers
Check the correct termination field per provider: OpenAI uses choices\[0\].finish\_reason === 'tool\_calls' \(or 'function\_call' in legacy\). Anthropic uses stop\_reason === 'tool\_use'. Map both to a unified 'tool\_call\_pending' signal in your agent loop. Also handle 'stop'/'end\_turn' for normal completion and 'length'/'max\_tokens' for truncation.
Journey Context:
Agent loops need to know: did the model finish, or is it requesting a tool call? The field names differ: OpenAI's finish\_reason vs Anthropic's stop\_reason, and the values differ: 'tool\_calls' vs 'tool\_use'. If you only check one convention, the agent either ignores tool call requests \(infinite loop with no tool execution\) or never terminates \(keeps calling tools\). Additionally, Anthropic has a 'stop\_sequence' stop\_reason when a custom stop sequence is hit, which has no direct OpenAI equivalent. Normalize all stop reasons at the adapter layer before the agent loop processes them.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:57:39.661759+00:00— report_created — created