promptdojo_

Reading the response — content blocks, stop_reason, usage — step 6 of 9

The code reads response["content"][0]["text"]. The model returned a tool_use block FIRST, then a text block. So content[0] is the tool_use — which has no text key. The code raises KeyError.

Fix the code to FILTER for text blocks first, then read the text. Use the comprehension pattern from step 5.

Expected output:

found.
The break is on line 10 — but read the whole snippet first.

full-screen editor opens — close anytime to keep reading.