
Claude's agentic loop explained: stopReason, tool_use, and the pattern behind every AI agent
If you've tried building an AI agent with Claude and Bedrock, you've hit stopReason . Maybe you ignored it, maybe you cargo-culted the pattern from a tutorial. Either way — here's what's actually happening and why it matters for production systems. TL;DR stopReason: "tool_use" → execute the tool, append result, loop again stopReason: "end_turn" → agent is done, return the response Always append the assistant message before tool results Never use text content checks as your stop condition Why this pattern exists Claude on Bedrock doesn't magically "know" to use tools. You have to implement the loop that lets it. The model's job is to reason about your task and signal what it needs — your code's job is to listen to that signal and respond correctly. The signal is stopReason . Everything else follows from there. The loop, step by step 1. Send message + tool definitions to Claude 2. Read stopReason from response 3a. If "tool_use" → run the tool → append result → go to step 1 3b. If "end_tu
Continue reading on Dev.to Python
Opens in a new tab



