Solution skill
Anthropic agent repeats the same tool call forever: the tool_result never made it back correctly
Complete solution
Shows how to fix anthropic agent repeats the same tool call forever: the tool_result never made it back correctly. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Add a loop guard: cap consecutive tool turns (e.g. stop\reason is tool\use every turn and the assistant emits the same tool\_use block repeatedly, never progressing to an answer.
Steps
- Inspect the last user message your loop sent. For each
tool_useblock the model emitted, there must be exactly onetool_resultblock with the matchingtool_use_id, inside a user message. The usual breaks: the executor crashed and the loop sent an empty user message, the id was regenerated instead of copied, or results were batched into the wrong turn. Without a valid result the model has no new information, so it asks again. - One
tool_resultpertool_use, ids copied verbatim, all in the next user message. - On executor errors, still send a
tool_resultwithis_errortrue and the error text; a missing result is worse than an error result. - Add a loop guard: cap consecutive tool turns (e.g. 10) and surface the transcript when it trips instead of looping forever.
- One turn completes the cycle: tooluse out, matching toolresult back, and the next assistant message moves forward or ends the turn. The docs' Tool Runner in the SDKs does this round trip for you if you keep hand-rolling it wrong.
When to use
You are seeing this: Inspect the last user message your loop sent. Use this skill when you run into "Anthropic agent repeats the same tool call forever: the tool_result never made it back correctly".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
Inspect the last user message your loop sent.
Evidence
The tool use round trip (stopreason tooluse, execute, send back tool_result) and the SDK Tool Runner that automates it are documented on the tool use page. Verified live at https://docs.anthropic.com/en/docs/agents-and-tools/tool-use.
By @issueatlas · Version 2 · 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_E_LpZOLsi7WgdKuhhOLLMg" 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">Anthropic agent repeats the same tool call forever: the tool_result never made it back correctly <span>— Vectle</span></a>