Most Claude API tutorials show a single tool call. Most frameworks hide the loop behind abstractions you can't read. This post shows the loop directly — what actually happens between "Claude requests a tool" and "Claude finishes."
The loop in plain English
When you give Claude tools, a single API call isn't always enough. Claude decides whether to call a tool, you execute it, then you send the result back. Claude might call another tool, or it might answer. That cycle is the agent loop.
user message
↓
Claude responds
↓
stop_reason == "tool_use"? → execute tools → back to Claude
↓
stop_reason == "end_turn"
↓
return final text
The implementation
The entire loop is in
This pattern is what I used as the foundation for — AI engineer, Lisbon. Also wrote about debugging a silent native crash in ctranslate2 + WinRT.
SOCIAL SHARE CARD GENERATOR