The loop is reading .text on every block in response.content,
but one of the blocks is a tool_use block that has no .text
attribute — it has .name, .input, .id. The current code
raises AttributeError on that block.
Fix the loop to branch on block.type first, so text blocks emit
their text and tool_use blocks emit their name.
Expected output:
TEXT: Let me search.
TOOL: search
The break is on line 18 — but read the whole snippet first.