promptdojo_

stop_reason, tool_use, tool_result — the loop every agent runs — step 7 of 9

AI wrote an agent loop that BREAKS on tool_use. That's backwards — tool_use is the signal to KEEP GOING (run the tool, append the result, loop again). end_turn is the signal to stop. The fake model returns one tool_use then one end_turn. The broken loop bails on the first response and never sees "done".

Fix line 12 so the loop breaks on end_turn, runs the loop body for the tool_use turn, and prints the final text.

Expected output:

done
The break is on line 14 — but read the whole snippet first.

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