Immutable solution version
OpenAI tool-call loop: the model keeps calling tools and never answers
Complete solution
An agent that calls tools forever is a loop with no guardrails, not a model bug. This skill shows how to read the loop signature in your logs and bound it with tool_choice, parallel_tool_calls, and a hard turn cap.
OpenAI tool-call loop: the model keeps calling tools and never answers
The symptom
The model calls tools turn after turn, cost climbs, and no final answer arrives. Or it calls the same tool with nearly identical arguments repeatedly. Logs show dozens of turns for a task that should take three.
Confirm the cause
Log every turn: turn number, tool name, an arguments hash, and whether the tool result changed anything. The signatures:
- Same tool, same args, repeated: the tool result is not giving the model what it needs, or the model ignores the result. The loop is in your tool design or instructions.
- New tool every turn, never converging: the task is under-specified. The model explores because nothing says when to stop.
- Many parallel calls per turn:
parallel_tool_callsdefaults to allowing multiple calls per turn. Fine for fan-out, terrible when each call spawns more calls.
The fix
tool_choice.auto(default) lets the model call zero, one, or many functions.requiredforces at least one call. A specific function forces exactly that one. When the model should answer instead of act, settool_choice: "none"for that turn.parallel_tool_calls: false. Ensures zero or one tool call per turn. Use it when parallel calls multiply the loop.- A hard turn cap in your code. The API will not stop the loop for you. Cap turns (ten is sane), and at the cap return the best answer so far or escalate to a human. This is the guardrail that saves the bill.
- Conclusive tool results. A tool that returns "not found" forever invites infinite retries. Make failure results explicit about the next step, and name the stopping condition in your instructions.
Verify the fix
Replay the looping task and confirm it terminates within the cap. Track turns per task as a metric and alert when p99 approaches the cap; rising turn counts warn before the next runaway bill.
Evidence
OpenAI's function calling guide documents toolchoice (auto calls zero, one, or multiple functions; required calls one or more; a specific function forces that call) and paralleltool_calls (false ensures zero or one tool call per turn). Turn caps and stopping conditions live in the calling code (https://platform.openai.com/docs/guides/function-calling).
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_j67lKtmuQylf2VnEcKMhHg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">OpenAI tool-call loop: the model keeps calling tools and never answers <span>— Vectle</span></a>