Build AI Apps with Python: AI Agent Loop — Chain Multiple Tools | Episode 10
5views
0018:44
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Claude becomes an agent! In this episode, we build a while loop that lets Claude call tools repeatedly until a task
is complete. No more one-call-one-answer — Claude now plans multi-step workflows on its own.
Two tasks prove it works: First, Claude creates a file and reads it back to verify (2 steps). Then Claude lists
files, reads each one, and writes a summary (3 steps). Claude decides the plan. You just provide the goal and the
tools.
Student code: https://github.com/GoCelesteAI/build-ai-apps-python/tree/main/episode10
Every keystroke is shown on screen with 3-second pauses so you can follow along at your own pace.
What You'll Learn:
• The agentic while True loop — runs until Claude is done
• How Claude chains multiple tool calls to complete a task
• Appending both assistant and tool_result messages each iteration
• Claude sees its full history and decides the next step
• Step counter to track how many tools Claude calls
• The break pattern — Claude stops when no more tools needed
• Two multi-step tasks: write+verify, list+read+summarize
• Running Python scripts with :!python %
Timestamps:
0:00 - Introduction
0:12 - One Call vs Many (Preview)
0:44 - Creating tool_chains.py
1:00 - Imports and setup
2:10 - Workspace directory
2:25 - File tools from Episode 9
6:35 - Save progress
6:45 - Dispatch and tool definitions
8:40 - Save definitions
8:50 - The agent function — the key concept
9:50 - while True — the agentic loop
11:30 - Tool check and dispatch
13:10 - Appending both messages — the critical step
14:15 - Step counter increment
14:25 - else break — Claude is done
15:05 - Two multi-step tasks
15:28 - Save and run
15:40 - Claude chains 2 steps, then 3 steps!
16:40 - Code review
17:00 - Recap: 3 Key Takeaways
17:32 - End Screen
Key Takeaways:
1. The while loop runs until Claude stops calling tools — each iteration is one step
2. Append both assistant and tool_result messages — Claude needs its full history
3. Claude decides the plan — you give the goal and tools, it figures out the steps
Tags
python ai agentclaude api tool chainsmulti-step toolswhile loop agentanthropic sdkagentic ai pythonai tool chainsclaude api pythonautonomous aiai tutorial 2026build ai apps pythonneovim tutorialgenerative ai pythonscreenkeycode along