Build the decide-act-observe loop for real — define tools, handle Claude's tool-use requests, run the loop until it finishes, and add error handling and stopping conditions.
Welcome to The Agent Loop with Claude, the second module — and the one where the agent stops being an idea and becomes running code. In Module 1 you learned the loop conceptually: the model decides, your code acts, the result feeds back, repeat. Now you’ll build exactly that, for real, using Claude’s tool use.
You’ll start by defining tools Claude can request and seeing how the model returns a tool_use block instead of a plain answer. You’ll learn to handle that request — run the actual function and feed the result back as a tool_result — and then assemble the full agent loop that keeps going until Claude returns a final answer. Finally you’ll make the loop robust: error handling so a failing tool doesn’t crash the agent, parallel tool calls, and stopping conditions that prevent runaway loops. The module ends by giving Atlas its first working tool-using loop.
Every piece of the loop in this module — tool dispatch, the message shapes, parallel tools, error handling, the step cap — is real, runnable Python, verified end to end. The Claude API calls use the low-cost claude-haiku-4-5 model. Start with Lesson 1 on tool use with Claude.
Complete all 5 lessons to finish the The Agent Loop with Claude module.