Intermediate

Build an AI Agent with Tool Use

Build a working tool-using agent against the Claude API: define a custom tool, handle the tool_use/tool_result loop manually, and add a second tool to see multi-tool orchestration in action.

~3.5h
0 / 7 steps
🚀
Intro

What you're building

Prerequisites: Python, an Anthropic API key, and completion of (or familiarity with) the Prompt Engineering Fundamentals project.

Tool use lets Claude call functions you define when it determines, based on your prompt and the tool's description, that doing so will help answer the request. Claude doesn't execute your function itself — it responds with a tool_use content block describing which tool it wants to call and with what arguments; your code runs the actual function and sends the result back as a tool_result, and Claude continues from there. This request-response pattern, repeated until Claude has what it needs to answer, is the agentic loop.

In this project you'll build that loop manually (rather than using a framework) so the mechanics are fully visible, define a calculator tool, then add a second tool to see how Claude decides which one to call and in what order.

Anthropic's own engineering guidance is explicit on this point: agents don't need to be sophisticated to be useful — start simple, and add complexity like multi-step orchestration only once a simpler single-tool setup demonstrably falls short.

🔨

Define your first tool

🔨

Implement the tool handler

🔨

Build the agentic loop

🔨

Add a second tool and observe tool selection

🎯
Secret Mission

Secret Mission: Add a tool that can fail

🧹
Wrap Up

Before You Go

Pro

Test what you just learned

Self-testing is one of the best ways to retain new skills. Unlock project quizzes to check your understanding.

Log in to unlock